Created
December 2, 2017 19:18
-
-
Save KumoKairo/4b3ddb68ce584fc4949f35f7557e4436 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
using UnityEditor; | |
using UnityEngine; | |
public class MyWindow : EditorWindow | |
{ | |
public MySO testNode; | |
[MenuItem("TEST/OPEN WINDOW")] | |
static void Init() | |
{ | |
MyWindow window = (MyWindow)EditorWindow.GetWindow(typeof(MyWindow)); | |
window.Show(); | |
} | |
private SerializedObject _testNodeSo; | |
void OnGUI() | |
{ | |
testNode = EditorGUILayout.ObjectField(testNode, typeof(MySO), false) as MySO; | |
if (testNode == null) | |
{ | |
EditorGUILayout.LabelField("Please create a 'MySO' and assign it"); | |
} | |
else | |
{ | |
if (_testNodeSo == null) | |
{ | |
_testNodeSo = new SerializedObject(testNode); | |
} | |
// Floats work as expected | |
EditorGUILayout.PropertyField(_testNodeSo.FindProperty("myFloat")); | |
// Events are wonky and do not update except on method change | |
EditorGUILayout.PropertyField(_testNodeSo.FindProperty("myEvent")); | |
if (GUI.changed) | |
{ | |
_testNodeSo.ApplyModifiedProperties(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment