-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorderable types! ReorderableCollection slightly changed.
- Loading branch information
Showing
3 changed files
with
142 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
|
||
namespace MyBox | ||
{ | ||
#region Default Reordable Types | ||
|
||
[Serializable] | ||
public class ReorderableGameObject : ReorderableArray<GameObject> | ||
{ | ||
} | ||
|
||
[Serializable] | ||
public class ReorderableGameObjectList : ReorderableList<GameObject> | ||
{ | ||
} | ||
|
||
[Serializable] | ||
public class ReorderableTransform : ReorderableArray<Transform> | ||
{ | ||
} | ||
|
||
[Serializable] | ||
public class ReorderableTransformList : ReorderableList<Transform> | ||
{ | ||
} | ||
|
||
#endregion | ||
|
||
|
||
[Serializable] | ||
public class ReorderableArray<T> : Internal.ReorderableBase | ||
{ | ||
public T[] Collection; | ||
} | ||
|
||
[Serializable] | ||
public class ReorderableList<T> : Internal.ReorderableBase | ||
{ | ||
public List<T> Collection; | ||
} | ||
} | ||
|
||
namespace MyBox.Internal | ||
{ | ||
[Serializable] | ||
public class ReorderableBase | ||
{ | ||
} | ||
} | ||
|
||
|
||
#if UNITY_EDITOR | ||
namespace MyBox.Internal | ||
{ | ||
using UnityEditor; | ||
using EditorTools; | ||
|
||
[CustomPropertyDrawer(typeof(ReorderableBase), true)] | ||
public class ReorderableTypePropertyDrawer : PropertyDrawer | ||
{ | ||
private ReorderableCollection _reorderable; | ||
|
||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) | ||
{ | ||
return _reorderable != null ? _reorderable.Height : base.GetPropertyHeight(property, label); | ||
} | ||
|
||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | ||
{ | ||
if (_reorderable == null) | ||
_reorderable = new ReorderableCollection(property.FindPropertyRelative("Collection"), true, true, property.displayName); | ||
|
||
EditorGUI.BeginProperty(position, label, property); | ||
_reorderable.Draw(position); | ||
EditorGUI.EndProperty(); | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.