public override void OnInspectorGUI()
        {
            if (GUILayout.Button("Regenerate ItemDatabase"))
            {
                ItemDatabaseUtility.GenerateItemDatabase();
            }
            GUILayout.Space(5);

            var listProperty = new SerializedObject((ItemDatabase)target).FindProperty("items");

            if (listProperty.propertyType == SerializedPropertyType.Generic)
            {
                // Use Copy() to avoid unwanted iterating.
                var listCount = listProperty.Copy().arraySize;
                GUILayout.Label("Items (" + listCount + ")");

                foreach (SerializedProperty itemProperty in listProperty)
                {
                    if (itemProperty.propertyType == SerializedPropertyType.ObjectReference)
                    {
                        using (new EditorGUI.DisabledScope(true)) {
                            EditorGUILayout.PropertyField(itemProperty, GUIContent.none);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void OnGUI()
        {
            Repaint();

            //! Should probably only run this line if an Item asset was created or deleted.
            var items = ScriptableObjectUtility.GetAllInstances <Item>().OrderBy(i => i.id).ToArray();

            EditorGUILayout.BeginHorizontal();
            selectedItem = DrawItemsSidebar(items);
            DrawSelectedItem();
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Generate ItemDatabase"))
            {
                ItemDatabaseUtility.GenerateItemDatabase();
            }
        }
Beispiel #3
0
        private void OnGUI()
        {
            // Only change what should be drawn (for the next frame?) during `Layout` event.
            if (Event.current.rawType == EventType.Layout)
            {
                //! Should probably only run this line if an Item asset was created or deleted.
                itemAssets = AssetsUtility.FindAllAssets <Item>().OrderBy(i => i.id).ToArray();
            }

            EditorGUILayout.BeginHorizontal();
            selectedItem = DrawItemsSidebar(itemAssets);
            DrawSelectedItem();
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Generate ItemDatabase"))
            {
                ItemDatabaseUtility.GenerateItemDatabase();
            }
        }