public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Draws open button.
            if (GUILayout.Button("Open Datastore", GUILayout.Height(30)))
            {
                DatastoreWindow.Init(AssetDatabase.GetAssetPath(target));
            }

            GUILayout.Space(16);

            // Draw all other properties.
            EditorGUI.BeginChangeCheck();
            SerializedProperty prop = serializedObject.GetIterator();
            bool foundNext          = prop.Next(true);

            while (foundNext)
            {
                if (prop.displayName != "Object Hide Flags" &&
                    prop.displayName != "Script" &&
                    prop.name != "m_elements" &&
                    prop.name != "m_editorVariables" &&
                    prop.name != "m_nextID")
                {
                    EditorGUILayout.PropertyField(prop, true);
                }
                foundNext = prop.NextVisible(false);
            }
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Пример #2
0
        private void OnGUI()
        {
            GUILayout.BeginVertical();

            //========================================================================================================//
            // Title
            //========================================================================================================//
            GUILayout.BeginHorizontal(EditorConstants.BoxStyle);
            DrawCenteredLabel("Datastore Library", EditorConstants.DatastoreTitleStyle);
            GUILayout.EndHorizontal();

            //========================================================================================================//
            // Draw Existing Datastores
            //========================================================================================================//
            scrollPos = GUILayout.BeginScrollView(scrollPos);
            GUILayout.BeginVertical(EditorConstants.BoxStyle);
            DrawCenteredLabel("Existing Datastores");
            GUILayout.Space(10);
            for (int i = 0; i < m_typesByName.Count; i++)
            {
                DrawCenteredLabel(m_typesByName[i], EditorConstants.LibraryTypeStyle);

                List <BaseDatastore> storesOfSameType = m_datastores[i];
                for (int j = 0; j < storesOfSameType.Count; j++)
                {
                    GUILayout.Space(2);

                    GUILayout.Label((j + 1) + ": " + storesOfSameType[j].name,
                                    EditorConstants.LibraryDatastoreNameStyle);
                    GUI.enabled = false;
                    EditorGUILayout.ObjectField(storesOfSameType[j], typeof(BaseDatastore), false);
                    GUI.enabled = true;

                    if (GUILayout.Button("Open Datastore", GUILayout.Height(30)))
                    {
                        DatastoreWindow.Init(AssetDatabase.GetAssetPath(storesOfSameType[j]));
                    }

                    GUILayout.Space(4);
                }

                GUILayout.Space(16);
            }

            GUILayout.EndVertical();
            GUILayout.EndScrollView();

            //========================================================================================================//
            // Draw the refresh button.
            //========================================================================================================//
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Refresh", GUILayout.Width(64)))
            {
                GetSortedDatastoreTypes();
                GetAllExistingDatastore();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }