mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] Extension
[+] Extension
This commit is contained in:
134
Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs
Normal file
134
Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
|
||||
#if !ODIN_INSPECTOR
|
||||
namespace Sirenix.OdinInspector
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public class ButtonAttribute : Attribute
|
||||
{
|
||||
public ButtonAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public ButtonAttribute(string name)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public sealed class ReadOnlyAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = false)]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public class ShowInInspectorAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public sealed class HideIfAttribute : Attribute
|
||||
{
|
||||
public string MemberName;
|
||||
public object Value;
|
||||
public bool Animate;
|
||||
|
||||
public HideIfAttribute(string memberName, bool animate = true)
|
||||
{
|
||||
this.MemberName = memberName;
|
||||
this.Animate = animate;
|
||||
}
|
||||
}
|
||||
|
||||
[DontApplyToListElements]
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public sealed class OnValueChangedAttribute : Attribute
|
||||
{
|
||||
public string MethodName;
|
||||
|
||||
public bool IncludeChildren;
|
||||
|
||||
public OnValueChangedAttribute(string methodName, bool includeChildren = false)
|
||||
{
|
||||
this.MethodName = methodName;
|
||||
this.IncludeChildren = includeChildren;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public class TableListAttribute : Attribute
|
||||
{
|
||||
public int DefaultMinColumnWidth = 40;
|
||||
public bool DrawScrollView = true;
|
||||
|
||||
public int MinScrollViewHeight = 350;
|
||||
|
||||
public int CellPadding = 2;
|
||||
|
||||
public int NumberOfItemsPerPage;
|
||||
|
||||
public bool IsReadOnly;
|
||||
|
||||
public bool ShowIndexLabels;
|
||||
|
||||
public int MaxScrollViewHeight;
|
||||
|
||||
public bool AlwaysExpanded;
|
||||
|
||||
public bool HideToolbar;
|
||||
|
||||
[SerializeField] [HideInInspector] private bool showPagingHasValue;
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public sealed class DontApplyToListElementsAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
[DontApplyToListElements]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public class PropertySpaceAttribute : Attribute
|
||||
{
|
||||
public float SpaceBefore;
|
||||
public float SpaceAfter;
|
||||
|
||||
public PropertySpaceAttribute()
|
||||
{
|
||||
this.SpaceBefore = 8f;
|
||||
this.SpaceAfter = 0.0f;
|
||||
}
|
||||
|
||||
public PropertySpaceAttribute(float spaceBefore)
|
||||
{
|
||||
this.SpaceBefore = spaceBefore;
|
||||
this.SpaceAfter = 0.0f;
|
||||
}
|
||||
|
||||
public PropertySpaceAttribute(float spaceBefore, float spaceAfter)
|
||||
{
|
||||
this.SpaceBefore = spaceBefore;
|
||||
this.SpaceAfter = spaceAfter;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public class LabelTextAttribute : Attribute
|
||||
{
|
||||
public string Text;
|
||||
|
||||
public LabelTextAttribute(string text)
|
||||
{
|
||||
this.Text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b7dfd2b954f77047a61bf4c505f8cc1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
34
Assets/TEngine/Runtime/Extension/TransformExtension.cs
Normal file
34
Assets/TEngine/Runtime/Extension/TransformExtension.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class TransformExtension
|
||||
{
|
||||
public static float YDeg(this Transform tran)
|
||||
{
|
||||
return tran.eulerAngles.y;
|
||||
}
|
||||
|
||||
public static void RemoveAllChildren(this Transform tran)
|
||||
{
|
||||
var count = tran.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
GameObject.DestroyImmediate(tran.GetChild(0).gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Transform> GetAllChildren(this Transform tran)
|
||||
{
|
||||
var count = tran.childCount;
|
||||
List<Transform> allTrans = new List<Transform>();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
allTrans.Add(tran.GetChild(i));
|
||||
}
|
||||
|
||||
return allTrans;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/Extension/TransformExtension.cs.meta
Normal file
11
Assets/TEngine/Runtime/Extension/TransformExtension.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59821d6add0226e40a841e85a2cba8ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user