예제 #1
0
        protected override void DrawDetail(InventoryItemBase item, int index)
        {
            EditorGUIUtility.labelWidth = EditorStyles.labelWidth;

            if (InventoryScriptableObjectUtility.isPrefabsSaveFolderSet == false)
            {
                EditorGUILayout.HelpBox("Prefab save folder is not set.", MessageType.Error);
                if (GUILayout.Button("Set prefab save folder"))
                {
                    InventoryScriptableObjectUtility.SetPrefabSaveFolder();
                }

                EditorGUIUtility.labelWidth = 0;
                return;
            }

            GUILayout.Label("Use the inspector if you want to add custom components.", EditorStyles.titleStyle);
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (GUILayout.Button("Convert type"))
            {
                var typePicker = ScriptPickerEditor.Get(typeof(InventoryItemBase));
                typePicker.Show();
                typePicker.OnPickObject += type =>
                {
                    ConvertThisToNewType(item, type);
                };

                return;
            }

            //EditorGUI.BeginChangeCheck();
            var instance = (InventoryItemBase)itemEditorInspector.target;

            itemEditorInspector.OnInspectorGUI();

            if (_previouslySelectedGUIItemName == "ItemEditor_itemName" && GUI.GetNameOfFocusedControl() != _previouslySelectedGUIItemName)
            {
                //UpdateAssetName(item);
                if (itemEditorInspector.target is InventoryItemBase)
                {
                    // TODO Remove this
                }
            }

            //if (EditorGUI.EndChangeCheck() && selectedItem != null)
            if (GUI.changed || !EditorIsSaved())
            {
                selectedItem = ItemManager.database.items[index] = UpdatePrefab(instance, item);
                UnityEditor.EditorUtility.SetDirty(selectedItem);

                SetEditorIsSaved();
            }

            _previouslySelectedGUIItemName = GUI.GetNameOfFocusedControl();

            ValidateItemFromCache(item);
            EditorGUIUtility.labelWidth = 0;
        }
        public override void Draw()
        {
            if (InventoryScriptableObjectUtility.isPrefabsSaveFolderSet == false || InventoryScriptableObjectUtility.isPrefabsSaveFolderValid == false)
            {
                GUI.color = Color.red;
            }

            EditorGUILayout.BeginHorizontal(EditorStyles.boxStyle);
            EditorGUILayout.LabelField(InventoryPro.ProductName + " prefab save folder: " + InventoryScriptableObjectUtility.prefabsSaveFolder);
            GUI.color = Color.white;

            if (GUILayout.Button("Set path", GUILayout.Width(100)))
            {
                InventoryScriptableObjectUtility.SetPrefabSaveFolder();
            }

            EditorGUILayout.EndHorizontal();

            base.Draw();
        }