Question by
TaesikYoon · Oct 13, 2015 at 02:25 AM ·
c#collisionarraycustom editorcustom-inspector
How can I modify 'SerializedProperty' that contain 'Array' in Custom inspector?
How can I modify 'SerializedProperty' that contain 'Array' in Custom inspector?
I'm trying to make it looks like below
myClass.cs
using UnityEngine;
using System.Collections;
public class myClass: MonoBehaviour {
// make string array
public string[] stringArray;
void Update () {
// Do something.
}
}
myClassEditor.cs
using UnityEngine;
using UnityEditor;
using System.Collection;
public class myClassEditor: Editor {
// Make SerializedObject
SerializedObject serializedObj;
// Make SerializedProperty
SerializedProperty stringArrayProp;
void OnEnable() {
serializedObj = new SerializedObject (target);
// Find property
stringArrayProp = serializedObj.FindProperty ("stringArray");
}
public override void OnInspectorGUI() {
serializedObj.Update();
// Draw EditorGUILayout
EditorGUILayout.PropertyField(stringArrayProp, new GUIContent("BookList"), true); // it's not working.
serializedObj.ApplyModifiedProperties ();
}
}
Does anyone know how to do this?
array.jpg
(29.8 kB)
Comment
Your answer
Follow this Question
Related Questions
Objects in Custom Editor Resetting on Play 1 Answer
No type in ObjectField created in uxml (UIElements) 3 Answers
CapsuleCollider check if grounded 1 Answer
How to Make A Character Stop At Wall? 0 Answers