public static void DrawComponentBox(MonoEntity entity, int index, SerializedProperty prop) { if (index >= entity.ComponentsCount) { return; } EntityGUI.Vertical(EntityGUI.GetColorStyle(entity.ComponentsCount, index), () => { DrawProperty(entity, index, prop); }); if (remove) { Remove(entity, index); } }
public override void OnInspectorGUI() { //DrawDefaultInspector(); entity = (MonoEntity)target; if (!entity.runTime) { EditorGUI.BeginChangeCheck(); } worldProviderProperty.objectReferenceValue = EditorGUILayout.ObjectField("World provider", worldProviderProperty.objectReferenceValue, typeof(EcsWorldProvider), false); if (entity.runTime) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button(new GUIContent("Kill Entity"), GUILayout.Width(154), GUILayout.Height(24))) { entity.entity.Destroy(); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.BeginHorizontal(); entity.destroyComponent = EditorGUILayout.Toggle("Destroy MonoBeh", entity.destroyComponent); entity.destroyObject = EditorGUILayout.Toggle("Destroy GO", entity.destroyObject); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Run Time", entity.runTime ? "✔" : "✘", EditorStyles.largeLabel); EditorGUILayout.LabelField($"ID:{entity.entity.GetInternalId().ToString()}"); EditorGUILayout.EndHorizontal(); EntityGUI.Vertical(GUI.skin.box, () => { if (entity.runTime) { if (!entity.entity.IsAlive()) { EditorGUILayout.LabelField("ENTITY DEAD", EditorStyles.whiteLargeLabel); return; } } EntityGUI.Horizontal(() => { EditorGUILayout.LabelField($"ECS Components [{entity.ComponentsCount.ToString()}]", EditorStyles.boldLabel); if (GUILayout.Button(new GUIContent("Clear", "Remove All Components"))) { RemoveAll(); } }); EntityGUI.Horizontal(() => { EditorGUILayout.LabelField("Add Component"); if (GUILayout.Button(new GUIContent("▼"), GUILayout.Width(21), GUILayout.Height(21))) { flowed = !flowed; } }); if (ComponentTypesList.Count > 1) { entity.lastIndex = EditorGUILayout.Popup(entity.lastIndex, ComponentTypesList.GetAllInArray()); } else { ComponentTypesList.Init(); } if (entity.lastIndex != 0) { AddComponent(entity.lastIndex); } EditorGUILayout.BeginVertical(GUI.skin.box); if (!flowed) { DrawComponents(); } EditorGUILayout.EndVertical(); }); if (entity.runTime) { return; } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(target); serializedObject.ApplyModifiedProperties(); } }