Exemple #1
0
        protected virtual void DrawToolbar()
        {
            if (ItemManager.instance != null && ItemManager.itemDatabaseLookup.hasSelectedDatabase)
            {
                if (AssetDatabase.GetAssetPath(ItemManager.database) != AssetDatabase.GetAssetPath(ItemManager.instance.sceneItemDatabase))
                {
                    EditorGUILayout.HelpBox("This scene contains a different database than is currently selected.", MessageType.Warning);
                    if (GUILayout.Button("Select scene's database"))
                    {
                        ItemManager.itemDatabaseLookup.SetDatabase(ItemManager.instance.sceneItemDatabase);
                    }
                }
            }

            EditorGUILayout.BeginHorizontal();
            GUI.color = Color.grey;
            if (GUILayout.Button("< DB", EditorStyles.toolbarStyle, GUILayout.Width(60)))
            {
                var selected = ItemManager.itemDatabaseLookup.ManuallySelectDatabase();
                if (selected == false)
                {
                    // Create a database
                    var db = ScriptableObjectUtility.CreateAssetChooseSaveFolder <ItemDatabase>("ItemDatabase.asset", true);
                    if (db != null)
                    {
                        ItemManager.itemDatabaseLookup.SetDatabase(db);
                    }
                }

                toolbarIndex = 0;
            }
            GUI.color = Color.white;

            int before = toolbarIndex;

            toolbarIndex = GUILayout.Toolbar(toolbarIndex, editorNames, EditorStyles.toolbarStyle);
            if (before != toolbarIndex)
            {
                editors[toolbarIndex].Focus();
            }

            EditorGUILayout.EndHorizontal();
        }