Пример #1
0
 private void InitData()
 {
     PotionInfo = (PotionData)CreateInstance(typeof(PotionData));
     PotionInfo.Randomize();
 }
Пример #2
0
    private void DrawSettings()
    {
        //Display in editor
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("ItemID");
        PotionInfo.ItemID = EditorGUILayout.TextField(PotionInfo.ItemID);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Name");
        PotionInfo.Name = EditorGUILayout.TextField(PotionInfo.Name);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Type");
        PotionInfo.potionBuff = (PotionBuff)EditorGUILayout.EnumPopup(PotionInfo.potionBuff);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Quality");
        PotionInfo.potionQuality = (PotionQuality)EditorGUILayout.EnumPopup(PotionInfo.potionQuality);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Description");
        PotionInfo.Description = EditorGUILayout.TextField(PotionInfo.Description);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Prefab");
        EditorGUILayout.ObjectField(PotionInfo.Prefab, typeof(GameObject), false);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Material");
        EditorGUILayout.ObjectField(PotionInfo.Material, typeof(Material), false);
        EditorGUILayout.EndHorizontal();

        if (PotionInfo.Prefab == null)
        {
            EditorGUILayout.HelpBox("This potion needs a [Prefab] before it can be created.", MessageType.Warning);
        }
        else if (PotionInfo.Name == null || PotionInfo.Name.Length < 1)
        {
            EditorGUILayout.HelpBox("This potion needs a [Name] before it can be created.", MessageType.Warning);
        }

        if (GUILayout.Button("New random potion", GUILayout.Height(40)))
        {
            //Get random potion data
            PotionInfo.Randomize();
        }

        if (GUILayout.Button("View Game Object", GUILayout.Height(40)))
        {
            //Spawns the gameobject in the scene
            PotionInfo.Spawn(PotionInfo.Prefab);
        }

        if (GUILayout.Button("Finish and Save", GUILayout.Height(40)))
        {
            //Save Potion as new asset
            SaveNewPotion();
        }
    }