コード例 #1
0
    /// <summary>
    /// 创建预置
    /// </summary>
    /// <param name="_prefab">prefab配置</param>
    void OnCreatePrefab(EditorEngineAssetConfig _prefab)
    {
        if (!EditorStrayFogUtility.assetBundleName.IsIllegalFile(_prefab.name))
        {
            bool isCreate = true;
            if (File.Exists(_prefab.fileName))
            {
                isCreate = EditorUtility.DisplayDialog("Exists Prefab", "The prefab '" + _prefab.fileName + "' already exists,are you sure want to cover it?", "Yes", "No");
            }
            if (isCreate)
            {
                _prefab.CreateAsset();
                GameObject prefab = PrefabUtility.LoadPrefabContents(_prefab.fileName);
                prefab.layer = LayerMask.NameToLayer("UI");
                prefab.AddComponent <RectTransform>();
                PrefabUtility.SaveAsPrefabAsset(prefab, _prefab.fileName);

                AssetDatabase.SaveAssets();
                EditorStrayFogApplication.PingObject(prefab);
                EditorStrayFogApplication.ExecuteMenu_AssetsRefresh();
                EditorUtility.DisplayDialog("Create New Window Prefab", "Create window prefab is complete.", "OK");
            }
        }
        else
        {
            EditorUtility.DisplayDialog("Illegal Name", "Window Name is not legal.", "OK");
        }
    }
コード例 #2
0
    /// <summary>
    /// 读取配置
    /// </summary>
    void OnRead()
    {
        EditorEngineAssetConfig absCfg = new EditorEngineAssetConfig(fileInSide,
                                                                     enEditorApplicationFolder.Game_Editor_Asmdef.GetAttribute <EditorApplicationFolderAttribute>().path,
                                                                     enFileExt.Asset, typeof(EditorAsmdefAsset).FullName);

        if (!absCfg.Exists())
        {
            absCfg.CreateAsset();
        }
        absCfg.LoadAsset();
        assetNode = (EditorAsmdefAsset)absCfg.engineAsset;
    }
コード例 #3
0
    /// <summary>
    /// 读取配置
    /// </summary>
    public void Read()
    {
        EditorEngineAssetConfig absCfg = new EditorEngineAssetConfig(fileInSide,
                                                                     enEditorApplicationFolder.Game_Editor_UIWindow.GetAttribute <EditorApplicationFolderAttribute>().path,
                                                                     enFileExt.Asset, typeof(EditorUIWindowAsset).FullName);

        if (!absCfg.Exists())
        {
            absCfg.CreateAsset();
        }
        absCfg.LoadAsset();
        assetNode     = (EditorUIWindowAsset)absCfg.engineAsset;
        ownerAssembly = EditorStrayFogAssembly.GetType(assetNode.name).Assembly;
    }
コード例 #4
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();
            }
        }
    }