-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commenetd out recursion test. No need for the spammy warnings!
- Loading branch information
foulston
committed
Nov 1, 2018
1 parent
96a7198
commit 22d0ab3
Showing
11 changed files
with
219 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEditor; | ||
using Malee.Editor; | ||
|
||
[CustomEditor(typeof(SurrogateTest))] | ||
public class SurrogateTestEditor : Editor { | ||
|
||
private ReorderableList list; | ||
private SerializedProperty myClassArray; | ||
|
||
private void OnEnable() { | ||
|
||
//custom list with more complex surrogate functionalty | ||
|
||
list = new ReorderableList(serializedObject.FindProperty("objects")); | ||
list.surrogate = new ReorderableList.Surrogate(typeof(GameObject), AppendObject); | ||
|
||
//myClassArray uses an auto surrogate property on the "ReorderableAttribute" | ||
//it's limited to only setting a property field to the dragged object reference. Still handy! | ||
|
||
myClassArray = serializedObject.FindProperty("myClassArray"); | ||
} | ||
|
||
public override void OnInspectorGUI() { | ||
|
||
GUILayout.Label("Drag a GameObject onto the lists. Even though the list type is not a GameObject!"); | ||
|
||
serializedObject.Update(); | ||
|
||
list.DoLayoutList(); | ||
EditorGUILayout.PropertyField(myClassArray); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
|
||
private void AppendObject(SerializedProperty element, Object objectReference, ReorderableList list) { | ||
|
||
//we can do more with a custom surrogate delegate :) | ||
|
||
element.FindPropertyRelative("gameObject").objectReferenceValue = objectReference; | ||
element.FindPropertyRelative("name").stringValue = objectReference.name; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using Malee; | ||
|
||
public class SurrogateTest : MonoBehaviour { | ||
|
||
[SerializeField] | ||
private MyClass[] objects; | ||
|
||
[SerializeField, Reorderable(surrogateType = typeof(GameObject), surrogateProperty = "gameObject")] | ||
private MyClassArray myClassArray; | ||
|
||
[System.Serializable] | ||
public class MyClass { | ||
|
||
public string name; | ||
public GameObject gameObject; | ||
} | ||
|
||
[System.Serializable] | ||
public class MyClassArray : ReorderableArray<MyClass> { | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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