- Home /
Question by
andylau-baby · Jun 30, 2017 at 02:35 AM ·
unity 5unityeditor
How to show a custom UnityEvent in custom class to custom Editor
code like this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEditor;
public class ExampleScript : MonoBehaviour {
[System.Serializable]
public class abc
{
[SerializeField]
public UnityEvent testEvent;
public bool invoked;
}
public abc[] custom_class_array;
}
namespace UnityStandardAssets.Utility.Inspector
{
#if UNITY_EDITOR
[CustomEditor(typeof(ExampleScript))]
public class ExampleSciptEditor : Editor
{
public override void OnInspectorGUI()
{
ExampleScript myscript = (ExampleScript)target;
for (int i = 0; i < myscript.custom_class_array.Length; i++)
{
SerializedProperty p = serializedObject.FindProperty("testEvent").GetArrayElementAtIndex(i);
EditorGUILayout.PropertyField(p, true);
serializedObject.ApplyModifiedProperties();
}
}
}
#endif
}
And return null , that mean unity can't find it? I find lot of method that only call from Behavior Script . THX
Comment
Your answer
Follow this Question
Related Questions
Vuforia Target Image scene not appearing in game 0 Answers
Unity Video Player Delays after Skip 0 Answers