I decided to make a beautiful component. I decided to make a button that adds a new field. A piece of code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; [CustomEditor(typeof(Starter))] public class StarterEditor : Editor { /// <summary> /// ΠΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ /// </summary> private Starter starter; /// <summary> /// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΠ° ΠΏΡΠΈ Π°ΠΊΡΠΈΠ²Π°ΡΠΈΠΈ /// </summary> public void OnEnable() { starter = (Starter)target; } /// <summary> /// ΠΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ Π²ΠΈΠ΄Π° ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΠ° /// </summary> public override void OnInspectorGUI() { int count = starter.managers.Count; EditorGUILayout.IntField("Π Π°Π·ΠΌΠ΅Ρ", count); //ΠΡΠ»ΠΈ ΡΠΆΠ΅ Π΅ΡΡΡ ΠΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΡ Π² ΠΏΠ°ΠΌΡΡΠΈ, ΡΠΎ Π²ΡΠ²Π΅ΡΡΠΈ ΠΈΡ
ΡΠΏΠΈΡΠΎΠΊ if (starter.managers.Count > 0) { foreach( var manage in starter.managers) { int index = starter.managers.IndexOf(manage); starter.managers[index] = (Manager.ManagerBase)EditorGUILayout.ObjectField("ΠΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ", manage, typeof(Manager.ManagerBase), false); } } else { /* ΠΡΠ»ΠΈ Π΅Π»Π΅ΠΌΠ΅Π½ΡΠΎΠ² Π² ΡΠΏΠΈΡΠΊΠ΅ Π½Π΅ΡΡ */ EditorGUILayout.LabelField("ΠΠ΅Ρ Π΅Π»Π΅ΠΌΠ΅Π½ΡΠΎΠ² Π² ΡΠΏΠΈΡΠΊΠ΅"); } //ΠΠ½ΠΎΠΏΠΊΠ° Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΡ Π½ΠΎΠ²ΠΎΠ³ΠΎ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΠ° if (GUILayout.Button("ΠΠΎΠ±Π°Π²ΠΈΡΡ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ")) { Manager.ManagerBase newManager = (Manager.ManagerBase)EditorGUILayout.ObjectField("ΠΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ", null, typeof(Manager.ManagerBase), false); } } } But whatever I enter into the if () {} construction is not executed. All connected, and inherited a class from Editor. I will be glad to any help.
EditorWindowandEditorWindowtoOnGUI? - Suvitruf β¦