Ejemplo n.º 1
0
        public static void OnEnable()
        {
            weaponID = ScriptableObject.CreateInstance <WeaponID>();
            if (weaponID != null)
            {
                weaponID.SetID(WeaponID.GenerateID());
                weaponID.SetDisplayName("Write weapon name here...");
            }
            Transform player = UEditorInternal.FindPlayer();

            if (player != null)
            {
                inventory = UEditorInternal.FindComponent <AdvancedInventory>(player);
            }

            weaponIDs    = UEditorInternal.FindAssetsByType <WeaponID>();
            toolbarItems = new string[2] {
                "New", "List"
            };
        }
Ejemplo n.º 2
0
        private static void WeaponIDsListGUI()
        {
            if (weaponIDs != null && weaponIDs.Count > 0)
            {
                GUILayout.BeginVertical(EditorStyles.helpBox);
                GUILayout.Space(3);

                for (int i = 0; i < weaponIDs.Count; i++)
                {
                    if (i >= weaponIDs.Count)
                    {
                        break;
                    }

                    Object _weaponID = weaponIDs[i];
                    if (_weaponID == null)
                    {
                        OnEnable();
                        continue;
                    }

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(3);
                    GUILayout.Label(_weaponID.name, EditorStyles.boldLabel);

                    GUI.color = new Color32(70, 150, 255, 255);
                    if (GUILayout.Button("Open", "ButtonLeft", GUILayout.Width(70)))
                    {
                        Selection.activeObject = _weaponID;
                    }

#if UNITY_EDITOR_OSX
                    EditorGUI.BeginDisabledGroup(true);
#endif

                    GUI.color = new Color32(70, 220, 70, 255);
                    if (GUILayout.Button("Duplicate", "ButtonMid", GUILayout.Width(70)))
                    {
                        string path = AssetDatabase.GetAssetPath(_weaponID);
                        string name = _weaponID.name;
                        path = path.Replace(_weaponID.name + ".asset", "");
                        AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(_weaponID), path + name + ".asset");
                        AssetDatabase.Refresh();
                        OnEnable();
                    }

#if UNITY_EDITOR_OSX
                    EditorGUI.EndDisabledGroup();
#endif

                    GUI.color = new Color32(255, 55, 55, 255);
                    if (GUILayout.Button("Delete", "ButtonRight", GUILayout.Width(70)))
                    {
                        if (UDisplayDialogs.Confirmation("Are you really want to delete \"" + _weaponID.name + "\" asset?"))
                        {
                            string path = AssetDatabase.GetAssetPath(_weaponID);
                            AssetDatabase.DeleteAsset(path);
                            AssetDatabase.Refresh();
                            OnEnable();
                            break;
                        }
                    }
                    GUI.color = Color.white;
                    GUILayout.Space(3);
                    GUILayout.EndHorizontal();

                    if (weaponIDs.Count > 1 && i < weaponIDs.Count - 1)
                    {
                        GUILayout.Space(3);
                        UEditor.HorizontalLine();
                        GUILayout.Space(3);
                    }
                    else
                    {
                        GUILayout.Space(3);
                    }
                }
                GUILayout.Space(3);
                GUILayout.EndVertical();
            }
            else
            {
                UEditorHelpBoxMessages.Message("WeaponID's not found...\n" + "Create new property or reload properties", MessageType.Warning);
            }

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(" Refresh Assets ", GUILayout.Width(105.5f)))
            {
                weaponIDs = UEditorInternal.FindAssetsByType <WeaponID>();
            }
            GUILayout.Space(8);
            GUILayout.EndHorizontal();
        }