Beispiel #1
0
    public static CriAtomWindowPrefs Load()
    {
        //Debug.Log("LoadPrefs \"" + criAtomWindowPrefsFilePath + "\"");
        CriAtomWindowPrefs preference = (CriAtomWindowPrefs)AssetDatabase.LoadAssetAtPath(criAtomWindowPrefsFilePath, typeof(CriAtomWindowPrefs));

        if (preference == null)
        {
            //Debug.Log("LoadPrefs preference is null.");
            preference = CreateInstance <CriAtomWindowPrefs> ();
            preference.Save();
        }

        //Debug.Log("LoadPrefs outputAssetsRoot is " + preference.outputAssetsRoot);

        return(preference);
    }
Beispiel #2
0
    private void GUIImportAssetsFromAtomCraft()
    {
        useCopyAssetsFromCriAtomCraft = GUILayout.Toggle(useCopyAssetsFromCriAtomCraft, "Use Copy Assets Folder (Created in CRI Atom Craft)");
        if (useCopyAssetsFromCriAtomCraft)
        {
            if (criAtomWindowPrefs == null)
            {
                criAtomWindowPrefs = CriAtomWindowPrefs.Load();
            }

            GUILayout.Space(12);


            EditorGUILayout.HelpBox("Copy \"Assets\" folder (created in CRI Atom Craft) to the \"Streaming Assets\" folder.\n1. Push \"Select Assets Root\" to select \"CRI Atom Craft\" output Assets Folder.\n2. Push \"Update Assets of \"CRI Atom Craft\"\"."
                                    , MessageType.Info);

            GUILayout.BeginHorizontal();
            GUILayout.Label("\"CRI Atom Craft\" Assets Path:");

            if (GUILayout.Button("Select Assets Root"))
            {
                string tmpStr = SelectFolder();
                if (tmpStr != String.Empty)
                {
                    //	Check Assets Root
                    bool isUnityAsesetsRoot = false;
                    {
                        string[] dirs = System.IO.Directory.GetDirectories(tmpStr);
                        foreach (string dir in dirs)
                        {
                            if (Path.GetFileName(dir) == "Editor"
                                )
                            {
                                isUnityAsesetsRoot = true;
                                break;
                            }
                        }
                    }
                    if (isUnityAsesetsRoot == false)
                    {
                        criAtomWindowPrefs.outputAssetsRoot = tmpStr;
                        criAtomWindowPrefs.Save();
                    }
                    else
                    {
                        Debug.LogError(String.Format("Choose \"CRI Atom Craft\" output Assets Path"));
                    }
                }
            }
            GUILayout.EndHorizontal();


            if (criAtomWindowPrefs != null)
            {
                criAtomWindowPrefs.outputAssetsRoot = GUILayout.TextArea(criAtomWindowPrefs.outputAssetsRoot);
            }
            //GUILayout.Label(Application.dataPath);

            GUI.color = Color.green;
            if (GUILayout.Button("Update Assets of \"CRI Atom Craft\""))
            {
                if (CheckPathIsAtomCraftAssetRoot(criAtomWindowPrefs.outputAssetsRoot) == false)
                {
                    return;
                }

                try
                {
                    CopyDirectory(criAtomWindowPrefs.outputAssetsRoot, Application.dataPath);
                    Debug.Log("Complete Update Assets of \"CRI Atom Craft\" " + criAtomWindowPrefs.outputAssetsRoot);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex.Message);
                    Debug.LogError("Failed to update Assets of \"CRI Atom Craft\" " + criAtomWindowPrefs.outputAssetsRoot);
                }
                AssetDatabase.Refresh();

                ReloadAcbInfo();
            }
        }
    }
    private void GUIImportAssetsFromAtomCraft()
    {
        if (criAtomWindowPrefs == null)
        {
            criAtomWindowPrefs = CriAtomWindowPrefs.Load();
        }

        useCopyAssetsFromCriAtomCraft = CriFoldout(useCopyAssetsFromCriAtomCraft, "Import Assets from Atom Craft Project");
        if (useCopyAssetsFromCriAtomCraft)
        {
            EditorGUI.indentLevel++;

            GUILayout.BeginHorizontal();
            {
                if (criAtomWindowPrefs != null)
                {
                    criAtomWindowPrefs.outputAssetsRoot = EditorGUILayout.TextField("Import From:", criAtomWindowPrefs.outputAssetsRoot);
                }

#if !OPENFOLDERPANEL_IS_BROKEN
                if (GUILayout.Button("...", EditorStyles.miniButton, GUILayout.Width(50)))
                {
                    string tmpPath = "";
                    string errorMsg;
                    tmpPath = EditorUtility.OpenFolderPanel("Select CRI Atom Craft output Assets Folder", criAtomWindowPrefs.outputAssetsRoot, "");
                    if (CheckPathIsAtomCraftAssetRoot(tmpPath, out errorMsg))
                    {
                        criAtomWindowPrefs.outputAssetsRoot = tmpPath;
                        criAtomWindowPrefs.Save();
                    }
                    else
                    {
                        Debug.LogWarning(errorMsg);
                    }
                }
#endif
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUI.color = Color.yellow;
                EditorGUILayout.PrefixLabel(" ");
                if (GUILayout.Button("Import Assets", GUILayout.Width(160), GUILayout.Height(40)))
                {
                    string errorMsg;
                    if (CheckPathIsAtomCraftAssetRoot(criAtomWindowPrefs.outputAssetsRoot, out errorMsg) == false)
                    {
                        Debug.LogWarning(errorMsg);
                    }
                    else
                    {
                        try {
                            CopyDirectory(criAtomWindowPrefs.outputAssetsRoot, Application.dataPath);
                            Debug.Log("[CRIWARE] Assets successfully imported from " + criAtomWindowPrefs.outputAssetsRoot);
                        } catch (Exception ex) {
                            Debug.LogError(ex.Message);
                            Debug.LogError("[CRIWARE] Failed to import assets from " + criAtomWindowPrefs.outputAssetsRoot);
                        }
                        AssetDatabase.Refresh();

                        ReloadAcbInfo();
                    }
                }
                GUI.color = Color.white;
                EditorGUILayout.HelpBox("Copy \"Assets\" folder (created in CRI Atom Craft) to the \"StreamingAssets\" folder.\nThe folder can be created by building with the \"With Unity Assets\" flag in CRI Atom Craft.", MessageType.Info);
            }
            GUILayout.EndHorizontal();

            EditorGUI.indentLevel--;
        }
    }