Exemplo n.º 1
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();
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// DrawAssetNodes
    /// </summary>
    private void DrawAssetNodes()
    {
        mSelectConfigIndex = EditorGUILayout.Popup("Select Config", mSelectConfigIndex, mConfigIndexs.ToArray());
        mWindowName        = EditorGUILayout.TextField("Window Name", mWindowName);

        EditorGUILayout.Separator();
        mValidateConfig = false;

        if (mPrefabConfig.paths != null && mPrefabConfig.paths.Length > mSelectConfigIndex)
        {
            mUIWindowPrefab.SetDirectory(OnGetDirectory(mPrefabConfig.paths[mSelectConfigIndex], mWindowName));
            mUIWindowPrefab.SetName(OnGetName(mWindowName));
            mValidateConfig = true;
        }

        if (mScriptConfig.paths != null && mScriptConfig.paths.Length > mSelectConfigIndex)
        {
            mUIWindowViewScript.SetDirectory(OnGetDirectory(mScriptConfig.paths[mSelectConfigIndex], mWindowName));
            mUIWindowViewScript.SetName(OnGetName(mWindowName));
            mValidateConfig &= true;
        }

        if (mValidateConfig)
        {
            #region 浏览按钮
            EditorGUILayout.Separator();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(string.Format("1. {0}", mUIWindowViewScript.fileName));
            if (GUILayout.Button("Brower"))
            {
                EditorStrayFogApplication.PingObject(mUIWindowViewScript.fileName);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(string.Format("2. {0}", mUIWindowPrefab.fileName));
            if (GUILayout.Button("Brower"))
            {
                EditorStrayFogApplication.PingObject(mUIWindowPrefab.fileName);
            }
            EditorGUILayout.EndHorizontal();
            #endregion

            EditorGUILayout.Separator();
            if (!string.IsNullOrEmpty(mWindowName))
            {
                if (!OnSameScript(mUIWindowViewScript, mWindowName))
                {
                    if (GUILayout.Button("Create Script"))
                    {
                        OnCreateScript(mUIWindowViewScript);
                    }
                    else if (File.Exists(mUIWindowViewScript.fileName) && GUILayout.Button("Create Prefab"))
                    {
                        if (!string.IsNullOrEmpty(mWindowName))
                        {
                            OnCreatePrefab(mUIWindowPrefab);
                        }
                    }
                }
            }
        }
        else
        {
            EditorGUILayout.HelpBox(string.Format("There is no script config for 【{0}】", mPrefabConfig.paths[mSelectConfigIndex]), MessageType.Info);
        }
    }