Пример #1
0
    /// <summary>
    /// 加载资源
    /// </summary>
    protected override void OnLoadAsset()
    {
        engineAsset = null;
        switch (ext)
        {
        case enFileExt.Prefab:
            #region Prefab
            engineAsset = AssetDatabase.LoadAssetAtPath <GameObject>(fileName);
            #endregion
            break;

        default:
            #region 默认
            Assembly assembly = null;
            Type     type     = EditorStrayFogAssembly.GetType(classFullName, ref assembly);
            if (type != null)
            {
                engineAsset = AssetDatabase.LoadAssetAtPath(fileName, type);
            }
            else
            {
                Debug.LogErrorFormat("Can not find 【{0}】asset in path 【{1}】.", classFullName, fileName);
            }
            #endregion
            break;
        }
    }
    /// <summary>
    /// 加载配置
    /// </summary>
    void OnLoadConfigs()
    {
        mExistsConfigs.Clear();
        mNoExistsConfigs.Clear();
        Type                    t     = EditorStrayFogAssembly.GetType("AbsRunningScriptableObject");
        List <Type>             types = EditorStrayFogAssembly.GetExportedTypes(t);
        EditorEngineAssetConfig temp  = null;

        if (types != null && types.Count > 0)
        {
            foreach (Type s in types)
            {
                if (!s.Equals(t))
                {
                    temp = new EditorEngineAssetConfig(s.Name,
                                                       enEditorApplicationFolder.Game_AssetBundles_Assets.GetAttribute <EditorApplicationFolderAttribute>().path,
                                                       enFileExt.Asset, s.FullName);
                    if (temp.Exists())
                    {
                        mExistsConfigs.Add(temp);
                    }
                    else
                    {
                        mNoExistsConfigs.Add(temp);
                    }
                }
            }
        }
    }
Пример #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>
    /// 创建资源
    /// </summary>
    protected override void OnCreateAsset()
    {
        switch (ext)
        {
        case enFileExt.Prefab:
            #region Prefab
            GameObject winPrefab   = new GameObject(name);
            GameObject emptyPrefab = PrefabUtility.SaveAsPrefabAsset(winPrefab, fileName);
            UnityEngine.Object.DestroyImmediate(winPrefab);
            #endregion
            break;

        default:
            #region 默认
            Assembly assembly = null;
            Type     type     = EditorStrayFogAssembly.GetType(classFullName, ref assembly);
            if (type != null)
            {
                UnityEngine.Object obj = (UnityEngine.Object)assembly.CreateInstance(type.FullName);
                if (obj != null)
                {
                    AssetDatabase.CreateAsset(obj, fileName);
                    AssetDatabase.SaveAssets();
                    EditorGUIUtility.PingObject(obj);
                }
                else
                {
                    throw new NullReferenceException(string.Format("Assembly【{0}】can not find type 【{1}】.", assembly.FullName, type.FullName));
                }
            }
            else
            {
                Debug.LogErrorFormat("Can not find 【{0}】asset script.", classFullName);
            }
            #endregion
            break;
        }
    }
Пример #5
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();
            }
        }
    }