Exemplo n.º 1
0
    /// <summary>
    /// Saves All of the Data Set in the UI
    /// </summary>
    void SaveKSIData()
    {
        //Save Data Up To Keyword Handlers
        EditorPrefs.SetString("XMLSceneName", KSIData.xmlSceneName);
        EditorPrefs.SetString("BasePath", KSIData.baseFilePath);
        EditorPrefs.SetString("XMLFileName", KSIData.xmlFileName);
        EditorPrefs.SetBool("UseFolders", KSIData.useFolders);
        //EditorPrefs.SetString("ExportFolder", KSIData.exportFolder);
        EditorPrefs.SetString("XMLFolder", KSIData.xmlFolder);

        int i = 0;

        //Clear Previous Keyword Handler Keys
        while (EditorPrefs.GetString("Key" + i) != "")
        {
            EditorPrefs.DeleteKey("Key" + i);
            EditorPrefs.DeleteKey("Handler" + i);
            i++;
        }

        //Save Keyword Handler Keys
        for (i = 0; i < KSIData.keywordList.Count; i++)
        {
            EditorPrefs.SetString("Key" + i, KSIData.keywordList[i].keyword);
            EditorPrefs.SetString("Handler" + i, KSIKeywordHandler.TypeToStr(KSIData.keywordList[i].handler));
        }

        i = 0;

        //Clear Previous Keyword Handler Keys
        while (EditorPrefs.GetString("LayerType" + i) != "")
        {
            EditorPrefs.DeleteKey("LayerType" + i);
            EditorPrefs.DeleteKey("HandlerLayer" + i);
            i++;
        }

        //Save Keyword Handler Keys
        for (i = 0; i < KSIKeywordHandler.layerList.Count; i++)
        {
            EditorPrefs.SetString("LayerType" + i, KSIKeywordHandler.TypeToStr(KSIKeywordHandler.layerList[i].handler));
            EditorPrefs.SetInt("HandlerLayer" + i, KSIKeywordHandler.layerList[i].layer);
        }

        //Save Data After Keyword Handlers
        EditorPrefs.SetInt("Index", KSIData.indexToChange);
        EditorPrefs.SetString("NewHandler", handlerName);
        EditorPrefs.SetString("ScenePath", KSIData.sceneFilePath);
        EditorPrefs.SetString("ImagePath", KSIData.imageFilePath);
        EditorPrefs.SetBool("UseCustomNames", KSIData.useCustomNames);
        EditorPrefs.SetString("CustomScene", KSIData.customSceneName);
        EditorPrefs.SetString("CustomImage", KSIData.customImageName);
        EditorPrefs.SetString("FileLastOpened", KSIData.filepathLastOpened);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Loads All of the Data Saved From the UI
    /// </summary>
    void LoadKSIData()
    {
        KSIData.xmlSceneName = EditorPrefs.GetString("XMLSceneName");
        KSIData.baseFilePath = EditorPrefs.GetString("BasePath");
        KSIData.xmlFileName  = EditorPrefs.GetString("XMLFileName");
        KSIData.useFolders   = EditorPrefs.GetBool("UseFolders");
        //KSIData.exportFolder = EditorPrefs.GetString("ExportFolder");
        KSIData.xmlFolder = EditorPrefs.GetString("XMLFolder");

        for (int i = 0; i < KSIData.keywordList.Count; i++)
        {
            if (KSIData.keywordList[i] == null)
            {
                KSIData.keywordList.Add(
                    new KSIKeywordHandler(
                        EditorPrefs.GetString("Key" + i),
                        KSIKeywordHandler.StrToType(EditorPrefs.GetString("Handler" + i))));
            }
            else
            {
                KSIData.keywordList[i].keyword = EditorPrefs.GetString("Key" + i);
                KSIData.keywordList[i].handler = KSIKeywordHandler.StrToType(EditorPrefs.GetString("Handler" + i));
            }
        }

        for (int i = 0; i < KSIKeywordHandler.layerList.Count; i++)
        {
            if (KSIKeywordHandler.layerList[i] == null)
            {
                KSIKeywordHandler.layerList.Add(
                    new KSIKeywordHandler.HandlerLayer(
                        KSIKeywordHandler.StrToType(EditorPrefs.GetString("LayerType" + i)),
                        EditorPrefs.GetInt("HandlerLayer")));
            }
            else
            {
                KSIKeywordHandler.layerList[i].handler = KSIKeywordHandler.StrToType(EditorPrefs.GetString("LayerType" + i));
                KSIKeywordHandler.layerList[i].layer   = EditorPrefs.GetInt("HandlerLayer");
            }
        }

        KSIData.keywordList.TrimExcess();

        KSIData.indexToChange      = EditorPrefs.GetInt("Index");
        handlerName                = EditorPrefs.GetString("NewHandler");
        KSIData.sceneFilePath      = EditorPrefs.GetString("ScenePath");
        KSIData.imageFilePath      = EditorPrefs.GetString("ImagePath");
        KSIData.useCustomNames     = EditorPrefs.GetBool("UseCustomNames");
        KSIData.customSceneName    = EditorPrefs.GetString("CustomScene");
        KSIData.customImageName    = EditorPrefs.GetString("CustomImage");
        KSIData.filepathLastOpened = EditorPrefs.GetString("FileLastOpened");
    }
Exemplo n.º 3
0
    /// <summary>
    /// Repaints the UI With the New List of Handler Layers
    /// </summary>
    public static void DisplayLayerList()
    {
        KSIKeywordHandler.RebuildLayerList();

        for (int i = 0; i < KSIKeywordHandler.layerList.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            KSIKeywordHandler.layerList[i].layer =
                EditorGUILayout.Popup(
                    "Handler " + KSIKeywordHandler.layerList[i].handler.ToString() + ":",
                    KSIKeywordHandler.layerList[i].layer,
                    InternalEditorUtility.layers);
            EditorGUILayout.EndHorizontal();
        }
    }
    public static void AddKeyword(int indexToChange)
    {
        int i = 0;

        if (KSIData.keywordList.Count == 0 || indexToChange == KSIData.keywordList.Count)
        {
            //New Null Reference is Added
            KSIData.keywordList.Add(new KSIKeywordHandler());
        }

        else if ((indexToChange < 0 &&
                  KSIUI.DisplayDialog("Error: Index Out of Range (Small)", "Provided Index is Too Small! Would You Like to Add a Keyword at the First Index?", "Add Keyword", "Do Not Add Keyword")))
        {
            //New Null Reference is Added At End of List
            KSIData.keywordList.Add(new KSIKeywordHandler());

            //Get the Last Index of the List
            i = KSIData.keywordList.Count - 1;

            //While We Can Still Move Up the List
            while (i > 0)
            {
                //Temporarily Grab Object at i
                KSIKeywordHandler temp = KSIData.keywordList[i];

                //Temporarily Grab Object Above i
                KSIKeywordHandler aboveTemp = KSIData.keywordList[i - 1];

                //Move the Object Above i Down
                KSIData.keywordList[i] = aboveTemp;

                //Move the Object at i Up
                KSIData.keywordList[i - 1] = temp;

                i--;
            }

            KSIUI.DisplayKeywordList();
        }

        else if ((indexToChange > KSIData.keywordList.Count - 1 &&
                  KSIUI.DisplayDialog("Error: Index Out of Range (Large)", "Provided Index is Too Large! Would You Like to Add a Keyword at the Last Index?", "Add Keyword", "Do Not Add Keyword")) ||
                 (indexToChange < KSIData.keywordList.Count - 1))
        {
            //New Null Reference is Added At End of List
            KSIData.keywordList.Add(new KSIKeywordHandler());

            //Get the Last Index of the List
            i = KSIData.keywordList.Count - 1;

            //While We Can Still Move Up the List
            while (i > indexToChange)
            {
                //Temporarily Grab Object at i
                KSIKeywordHandler temp = KSIData.keywordList[i];

                //Temporarily Grab Object Above i
                KSIKeywordHandler aboveTemp = KSIData.keywordList[i - 1];

                //Move the Object Above i Down
                KSIData.keywordList[i] = aboveTemp;

                //Move the Object at i Up
                KSIData.keywordList[i - 1] = temp;

                i--;
            }

            KSIUI.DisplayKeywordList();
        }
    }
Exemplo n.º 5
0
    private void OnGUI()
    {
        GUILayout.Label("Settings for File Import", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        if (GUILayout.Button("Open File Browser"))
        {
            //Temporarily Prevent Importer From Loading Data When Refocusing on Window
            //Otherwise the Data We Set Will Disappear
            loadData = false;

            //Set UI Data When User Chooses a XML File
            SetFilePathData(EditorUtility.OpenFilePanel("Select XML File To Import With", KSIData.filepathLastOpened ?? Application.dataPath, ""));
            SaveKSIData();
        }

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        EditorGUILayout.Space();

        GUILayout.Label("Exporter Data", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        KSIData.xmlSceneName = EditorGUILayout.TextField("Scene Name: ", KSIData.xmlSceneName);
        KSIData.baseFilePath = EditorGUILayout.TextField("File Path:", KSIData.baseFilePath);
        KSIData.xmlFileName  = EditorGUILayout.TextField("XML File Name: ", KSIData.xmlFileName);

        EditorGUILayout.Space();

        KSIData.useFolders = EditorGUILayout.BeginToggleGroup("Used Sub-Folders", KSIData.useFolders);
        //KSIData.exportFolder = EditorGUILayout.TextField("Export Folder:", KSIData.exportFolder);
        KSIData.xmlFolder = EditorGUILayout.TextField("XML Folder:", KSIData.xmlFolder);
        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        EditorGUILayout.Space();

        GUILayout.Label("Keywords", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        keywordScrollPosition = EditorGUILayout.BeginScrollView(keywordScrollPosition, GUILayout.Width(position.width - 20), GUILayout.Height(100));
        DisplayKeywordList();
        EditorGUILayout.EndScrollView();
        EditorGUILayout.Space();
        KSIData.indexToChange = EditorGUILayout.IntField("Index to Change:", KSIData.indexToChange);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Keyword At Index " + KSIData.indexToChange))
        {
            KSIKeywordHandler.AddKeyword(KSIData.indexToChange);
        }

        if (GUILayout.Button("Remove Keyword At Index " + KSIData.indexToChange))
        {
            KSIKeywordHandler.RemoveKeyword(KSIData.indexToChange);
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        GUILayout.Label("Handler Layers", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        layerScrollPosition = EditorGUILayout.BeginScrollView(layerScrollPosition, GUILayout.Width(position.width - 20), GUILayout.Height(100));
        DisplayLayerList();
        EditorGUILayout.EndScrollView();

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        EditorGUILayout.Space();

        GUILayout.Label("Add/Remove Keyword Handlers", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        handlerName = EditorGUILayout.TextField("New Handler Name:", handlerName);

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Create " + ((handlerName == "") ? "???" : handlerName.ToUpper())))
        {
            if (handlerName == "")
            {
                DisplayDialog("Error: No Handler Specified", "There is No Handler Specified!\n\nCannot Add!", "Okay");
            }
            else
            {
                KSITemplateManager.AddHandler(handlerName);
                AssetDatabase.Refresh();
            }
        }

        if (GUILayout.Button("Remove " + ((handlerName == "") ? "???" : handlerName.ToUpper())))
        {
            if (handlerName == "")
            {
                DisplayDialog("Error: No Handler Specified", "There is No Handler Specified!\n\nCannot Remove!", "Okay");
            }
            else
            {
                KSITemplateManager.RemoveHandler(handlerName);
                AssetDatabase.Refresh();
            }
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        EditorGUILayout.Space();

        GUILayout.Label("Settings For Scene Saving", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        KSIData.sceneFilePath = EditorGUILayout.TextField("Scene File Path:", KSIData.sceneFilePath);
        KSIData.imageFilePath = EditorGUILayout.TextField("Image File Path:", KSIData.imageFilePath);

        EditorGUILayout.Space();

        KSIData.useCustomNames  = EditorGUILayout.BeginToggleGroup("Use Custom Names", KSIData.useCustomNames);
        KSIData.customSceneName = EditorGUILayout.TextField("Custom Scene Name:", KSIData.customSceneName);
        KSIData.customImageName = EditorGUILayout.TextField("Custom Image Set Name:", KSIData.customImageName);
        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.Space();

        /*
         * if(GUILayout.Button("Update Importer"))
         * {
         *
         *  DisplayKeywordList();
         *  DisplayLayerList();
         *
         * }
         *
         * EditorGUILayout.Space();
         */

        if (GUILayout.Button("Import Scene"))
        {
            KSImporter.StartImport();
        }
    }
Exemplo n.º 6
0
 /// <summary>
 /// Get and Set the Appropriate Handler Information for Importing Into the Scene
 /// </summary>
 /// <param name="textureData">The Image That We Will Be Working On</param>
 public static void SetHandler(ref TextureData textureData)
 {
     textureData.data.handler = KSIKeywordHandler.FindHandler(textureData.data.Type);
 }