Esempio n. 1
0
    /// <summary>
    /// 创建脚本
    /// </summary>
    /// <param name="_viewScript">视图脚本</param>
    void OnCreateScript(EditorTextAssetConfig _viewScript)
    {
        if (!EditorStrayFogUtility.assetBundleName.IsIllegalFile(_viewScript.name))
        {
            bool   hasScript     = false;
            string hasScriptPath = string.Empty;
            if (mScriptConfig.paths != null && mScriptConfig.paths.Length > 0)
            {
                for (int i = 0; i < mScriptConfig.paths.Length; i++)
                {
                    mTempUIWindowViewScript.SetDirectory(
                        OnGetDirectory(mScriptConfig.paths[i], Path.GetFileName(_viewScript.directory)));
                    mTempUIWindowViewScript.SetName(_viewScript.name);
                    hasScript    |= File.Exists(mTempUIWindowViewScript.fileName);
                    hasScriptPath = mTempUIWindowViewScript.fileName;
                    if (hasScript)
                    {
                        break;
                    }
                }
            }

            if (hasScript)
            {
                EditorUtility.DisplayDialog("Exists Script",
                                            "The script 【" + _viewScript.name + "】 already exists in 【" + hasScriptPath + "】.",
                                            "OK");
            }
            else
            {
                string windowTemplate = EditorResxTemplete.UIWindowViewTemplete;
                windowTemplate = windowTemplate.Replace("#NAME#", _viewScript.name);
                _viewScript.SetText(windowTemplate);
                _viewScript.CreateAsset();
                EditorStrayFogApplication.ExecuteMenu_AssetsRefresh();
                EditorUtility.DisplayDialog("Create New Window Script", "Create window scripts is complete.", "OK");
            }
        }
        else
        {
            EditorUtility.DisplayDialog("Illegal Name", "Window Name is not legal.", "OK");
        }
    }
Esempio n. 2
0
    /// <summary>
    /// OnGUI
    /// </summary>
    void OnGUI()
    {
        mNewAssetName = EditorGUILayout.TextField("资源名称", mNewAssetName);
        if (!string.IsNullOrEmpty(mNewAssetName.Trim()))
        {
            mScriptConfig.SetName(mNewAssetName);
            mAssetConfig.SetName(mNewAssetName);
            mAssetConfig.SetType(mNewAssetName);
            EditorGUILayout.LabelField("1." + mScriptConfig.fileName);
            EditorGUILayout.LabelField("2." + mAssetConfig.fileName);
            mScriptContent = mTxtScriptTemplete.Replace("#ClassName#", mNewAssetName);
            mScriptConfig.SetText(mScriptContent);
            EditorGUILayout.HelpBox(mScriptContent, MessageType.Info);

            if (File.Exists(mAssetConfig.fileName))
            {
                if (GUILayout.Button("Brower"))
                {
                    EditorStrayFogApplication.PingObject(mAssetConfig.fileName);
                }
            }
            else if (EditorStrayFogAssembly.IsExistsTypeInApplication(mNewAssetName))
            {
                if (GUILayout.Button("Create Asset"))
                {
                    mAssetConfig.CreateAsset();
                    EditorUtility.DisplayDialog("Custom Asset ", string.Format("Create Asset【{0}】success , path is '{1}'.", mAssetConfig.name, mAssetConfig.fileName), "OK");
                    EditorStrayFogApplication.ExecuteMenu_AssetsRefresh();
                }
            }
            else if (GUILayout.Button("Create Script"))
            {
                mScriptConfig.CreateAsset();
                EditorStrayFogApplication.ExecuteMenu_AssetsRefresh();
            }
        }
    }