Exemple #1
0
    void OnGUI()
    {
        Repaint();
        EditorUtility.SetDirty(this);

        popupselction = EditorGUILayout.Popup(popupselction, currentSpellsAsArray);
        if (workingSpell == null)
        {
            if (popupselction != 0)
            {
                try
                {
                    workingSpell = SpellAction.ParseAndCreateSpell("Spells/" + currentSpellsAsArray[popupselction]);
                }
                catch
                {
                    workingSpell = null;
                }
            }
        }
        else
        {
            workingSpell.DrawEditor();

            if (GUILayout.Button("Save"))
            {
                FileStream f        = File.Open("Assets/Resources/Spells/" + currentSpellsAsArray[popupselction] + ".json", FileMode.OpenOrCreate);
                string     contents = workingSpell.convertToJSONString();
                f.Write(Encoding.ASCII.GetBytes(contents), 0, Encoding.ASCII.GetByteCount(contents));
                f.Close();
            }
        }
    }