Example #1
0
    public void ExportCurrentUI()
    {
        //if (changeLayer)
        //{
        // 去掉一些残留的Clone
        //var allTrans = GameObject.FindObjectsOfType<Transform>();
        //for (var i = allTrans.Length - 1; i >= 0 ; i--)
        //{
        //    var child = allTrans[i];
        //    if (child != null && child.gameObject.name.EndsWith("Window(Clone)"))
        //    {
        //        GameObject.DestroyImmediate(child.gameObject);
        //    }
        //}
        EditorApplication.SaveScene(); // 强制保存一下,保证一些Prefab更新

        //}

        foreach (var windowAsset in GameObject.FindObjectsOfType <KUIWindowAsset>())
        {
            var uiName          = windowAsset.name;
            var tempPanelObject = CreateTempPrefab(windowAsset.gameObject);

            if (ExportCurrentUIEvent != null)
            {
                ExportCurrentUIEvent(this, UIScenePath, uiName, tempPanelObject);
            }
            else
            {
                KBuildTools.BuildAssetBundle(tempPanelObject, GetBuildRelPath(uiName));
            }
            DestroyTempPrefab(tempPanelObject);
        }
    }
Example #2
0
    //
    /// <summary>
    /// 如果非realBuild,僅返回最終路徑
    /// DoBuildAssetBundle和__DoBuildScriptableObject有两个开关,决定是否真的Build
    /// realBuildOrJustPath由外部传入,一般用于进行md5比较后,传入来的,【不收集Build缓存】 TODO:其实可以收集的。。
    /// IsJustCollect用于全局的否决真Build,【收集Build缓存】
    /// </summary>
    /// <param name="path"></param>
    /// <param name="asset"></param>
    /// <param name="realBuildOrJustPath"></param>
    /// <returns></returns>
    public static CDepCollectInfo DoBuildAssetBundle(string path, UnityEngine.Object asset,
                                                     bool realBuildOrJustPath = true)
    {
        path = Path.ChangeExtension(path, AppEngine.GetConfig("AssetBundleExt"));
        //asset.name = fullAssetPath;
        var hasBuilded = false;

        if (!BuildRecord.ContainsKey(path))
        {
            if (realBuildOrJustPath)
            {
                AddCache(path);
            }
            if (IsJustCollect)
            {
                AddCache(path);
            }
            if (!IsJustCollect && realBuildOrJustPath)
            {
                //BuildedCache[fullAssetPath] = true;
                KBuildTools.BuildAssetBundle(asset, path);
                hasBuilded = true;
            }
        }

        return(new CDepCollectInfo
        {
            Path = path,
            Asset = asset,
            HasBuild = hasBuilded,
        });
    }
Example #3
0
        public static void ExportCurrentUI()
        {
            var UIName = Path.GetFileNameWithoutExtension(EditorApplication.currentScene);

            var uiRoot = GameObject.Find("UI");

            KBuildTools.BuildAssetBundle(uiRoot, GetBuildRelPath(UIName));
        }
Example #4
0
    public static uint BuildScriptableObject <T>(T scriptObject, string path, BuildTarget buildTarget,
                                                 KResourceQuality quality) where T : ScriptableObject
    {
        const string tempAssetPath = "Assets/~Temp.asset";

        AssetDatabase.CreateAsset(scriptObject, tempAssetPath);
        T tempObj = (T)AssetDatabase.LoadAssetAtPath(tempAssetPath, typeof(T));

        if (tempObj == null)
        {
            throw new System.Exception();
        }

        uint crc = KBuildTools.BuildAssetBundle(tempObj, path, buildTarget, quality);

        AssetDatabase.DeleteAsset(tempAssetPath);

        return(crc);
    }