Esempio n. 1
0
        private void AddRarity()
        {
            // Name
            // Tooltip
            // Color
            // Statboost
            // Sprite

            selectedItem.Name      = EditorGUILayout.TextField("Name: ", selectedItem.Name);
            selectedItem.ToolTip   = EditorGUILayout.TextField("ToolTip: ", selectedItem.ToolTip);
            selectedItem.StatBoost = EditorGUILayout.DoubleField("StatBoost: ", selectedItem.StatBoost);
            selectedItem.Color     = EditorGUILayout.ColorField("Text Color: ", selectedItem.Color);

            if (selectedItem.Icon != null)
            {
                selectedTexture = selectedItem.Icon.texture;
            }
            else
            {
                selectedTexture = null;
            }

            if (GUILayout.Button(selectedTexture, GUILayout.Width(SPRITE_BUTTON_SIZE), GUILayout.Height(SPRITE_BUTTON_SIZE)))
            {
                int controllerID = EditorGUIUtility.GetControlID(FocusType.Passive);
                EditorGUIUtility.ShowObjectPicker <Sprite>(null, true, null, controllerID);
            }

            string commandName = Event.current.commandName;

            if (commandName == "ObjectSelectorUpdated")
            {
                selectedItem.Icon = (Sprite)EditorGUIUtility.GetObjectPickerObject();
                Repaint();
            }

            if (GUILayout.Button("Save"))
            {
                if (selectedItem == null)
                {
                    return;
                }

                rarityDatabase.Add(selectedItem);
                selectedItem = new ISRarity();
            }
        }