diff --git a/Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs b/Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs new file mode 100644 index 00000000..91e258cc --- /dev/null +++ b/Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs @@ -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 \ No newline at end of file diff --git a/Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs.meta b/Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs.meta new file mode 100644 index 00000000..44752873 --- /dev/null +++ b/Assets/TEngine/Runtime/Extension/OdinInspectorExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1b7dfd2b954f77047a61bf4c505f8cc1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TEngine/Runtime/Extension/TransformExtension.cs b/Assets/TEngine/Runtime/Extension/TransformExtension.cs new file mode 100644 index 00000000..9ee68723 --- /dev/null +++ b/Assets/TEngine/Runtime/Extension/TransformExtension.cs @@ -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 GetAllChildren(this Transform tran) + { + var count = tran.childCount; + List allTrans = new List(); + for (int i = 0; i < count; i++) + { + allTrans.Add(tran.GetChild(i)); + } + + return allTrans; + } + } +} \ No newline at end of file diff --git a/Assets/TEngine/Runtime/Extension/TransformExtension.cs.meta b/Assets/TEngine/Runtime/Extension/TransformExtension.cs.meta new file mode 100644 index 00000000..72c0d7fb --- /dev/null +++ b/Assets/TEngine/Runtime/Extension/TransformExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 59821d6add0226e40a841e85a2cba8ec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: