Пример #1
0
    public static void ExportSprite()
    {
        string sourcePath = HS_Path.CombinePath("Assets", "SubAssets", "Raw", "Sprite");
        string targetPath = HS_Path.CombinePath("Assets", "SubAssets", "Res", "Prefabs", "Sprite");

        string[] allFolders = AssetDatabase.GetSubFolders(sourcePath);
        for (int i = 0; i < allFolders.Length; i++)
        {
            string[] pathDatas = HS_Path.SplitPath(allFolders[i]);
            string   tagName   = pathDatas[pathDatas.Length - 1];
            string[] allAssets = AssetDatabase.FindAssets("t:Sprite", new string[] { allFolders[i] });
            for (int j = 0; j < allAssets.Length; j++)
            {
                string          assetPath = AssetDatabase.GUIDToAssetPath(allAssets[j]);
                TextureImporter ti        = TextureImporter.GetAtPath(assetPath) as TextureImporter;
                FormatTexture(ti, tagName);

                Sprite     sprite = AssetDatabase.LoadAssetAtPath <Sprite>(assetPath);
                GameObject go     = new GameObject(sprite.name);
                go.AddComponent <SpriteRenderer>().sprite = sprite;

                if (!AssetDatabase.IsValidFolder(HS_Path.CombinePath(targetPath, tagName)))
                {
                    AssetDatabase.CreateFolder(targetPath, tagName);
                }
                string prefabPath = HS_Path.CombinePath(HS_Path.CombinePath(targetPath, tagName), sprite.name + ".prefab");
                PrefabUtility.CreatePrefab(prefabPath, go);
                GameObject.DestroyImmediate(go);
            }
        }

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        Debug.Log("Done!");
    }
Пример #2
0
        public void ExportAssetbundle(Object[] selectionGameObjects)
        {
            if (selectionGameObjects == null || selectionGameObjects.Length == 0)
            {
                return;
            }
            AssetDatabase.SaveAssets();

            foreach (var v in _BuildTargetMap)
            {
                foreach (Object obj in selectionGameObjects)
                {
                    if (obj is GameObject || obj is Texture2D)
                    {
                        AssetDatabase.Refresh();
                        string locationPathName = RootPath + "/" + v.Value + "/" + obj.name + ".assetbundle";
                        HS_Directory.CreateDirectory(HS_Path.GetDirectoryName(locationPathName));
                        BuildPipeline.BuildAssetBundle(obj, null, locationPathName, BuildAssetBundleOptions.CollectDependencies, v.Key);
                    }
                    else
                    {
                        D.LogForce(obj.name + " 不是预制体");
                    }
                }
            }
            this.OpenFolder();
            EditorUtility.DisplayDialog("提示", "打包完成", "确认");
        }
Пример #3
0
        static public void BuildForWindows(HS_EditDefine.HS_ChannelDefine channelDefine)
        {
            LoadConfig();

            ChannelConfig channelConfig = S_AllChannelConfig[channelDefine.ToString()];
            //string channel = channelConfig.channel;
            string packerName = channelConfig.packerName;
            string rootPath   = S_RootPath;

            PlayerSettings.bundleIdentifier            = packerName;
            PlayerSettings.defaultInterfaceOrientation = UIOrientation.LandscapeLeft;
            string path = rootPath + "/Client/Windows";

            HS_Directory.CreateDirectory(path);

            try
            {
                HS_Base.SystemDeleteFolder(path);
            }
            catch (System.Exception _e)
            {
                D.LogForce("Ignore: " + _e.ToString());
            }

            string lastDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone);

            if (!string.IsNullOrEmpty(channelConfig.defineSymbols))
            {
                PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, channelConfig.defineSymbols);
            }
            else
            {
                PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, "");
            }
            if (!string.IsNullOrEmpty(lastDefineSymbols))
            {
                PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, lastDefineSymbols);
            }

            path += "/" + packerName + ".exe";

            //FilterEditorDLL(FilterEditorDLLModel.Assets2Backups);
            //更新SVN并且拷贝到streamingAssets
            SVNUpdate(RuntimePlatform.WindowsPlayer);

            BuildPipeline.BuildPlayer(GetBuildScenes(), path, BuildTarget.StandaloneWindows64, BuildOptions.None);
            //FilterEditorDLL(FilterEditorDLLModel.Backups2Assets);
            RemoveSVNResources();
            AssetDatabase.Refresh();
            System.Diagnostics.Process.Start(HS_Path.GetDirectoryName(path));
        }
Пример #4
0
        public static void SVNUpdate(RuntimePlatform platform)
        {
            string platformAssets = HS_PlatformRes.Directory[platform];

            SVNSetiingWindows.Update();
            string streamingAssetsPath = Application.streamingAssetsPath;

            HS_Directory.CreateDirectory(streamingAssetsPath);

            s_CopyFolder.Clear();
            foreach (string p in SVNSetiingWindows.UpdatePaths)
            {
                string folderName     = HS_Path.GetCurrentFolder(p);
                string fullFolderName = streamingAssetsPath + @"/" + folderName;
                try
                {
                    HS_Base.SystemDeleteFolder(fullFolderName);
                }
                catch (System.Exception _e)
                {
                    D.LogForce("Ignore: " + _e.ToString());
                }
            }
            AssetDatabase.Refresh();

            foreach (string p in SVNSetiingWindows.UpdatePaths)
            {
                string dstPath = streamingAssetsPath + @"/";

                if (p.Contains("Assets"))
                {
                    if (!p.Contains(platformAssets))
                    {
                        continue;
                    }
                    dstPath += platformAssets;
                }
                else
                {
                    dstPath += HS_Path.GetCurrentFolder(p);
                }
                s_CopyFolder.Add(dstPath);
                HS_Base.SystemCopyDirectory(p, dstPath, new string[] { ".svn", ".bat", ".dll" });
            }
            AssetDatabase.Refresh();
            HS_GenerateMD5.GenerateMD5(streamingAssetsPath, "");
        }
Пример #5
0
        public void UpdateLayout()
        {
            string gridCellPath = HS_Path.CombinePath("Assets", "SubAssets", "Res", "Prefabs", "UIListCell");

            if (mCellPrefab == null)
            {
                Debug.Log(mCellPrefabName);
                if (mCellPrefabName != "")
                {
                    string cellPrefabPath = HS_Path.CombinePath(gridCellPath, mCellPrefabName + ".prefab");
                    Debug.Log(cellPrefabPath);
                    GameObject prefab = UnityEditor.AssetDatabase.LoadAssetAtPath(cellPrefabPath, typeof(GameObject)) as GameObject;
                    mCellPrefab      = HS_ViewManager.UIAddChild(mGridContent.gameObject, prefab);
                    mCellPrefab.name = "CellPrefab";
                }
            }
            if (mGridContent == null)
            {
                Debug.LogError("Not specified GridContent");
                return;
            }
            if (mCellPrefab == null)
            {
                Debug.LogError("Not specified CellPrefab");
                return;
            }
            for (int i = mGridContent.transform.childCount - 1; i >= 0; i--)
            {
                Transform t = mGridContent.transform.GetChild(i);
                if (t.gameObject != mCellPrefab)
                {
                    DestroyImmediate(t.gameObject);
                }
            }
            int count = mCellCount - mGridContent.transform.childCount;

            for (int i = 0; i < count; i++)
            {
                GameObject cell = HS_ViewManager.UIAddChild(mGridContent.gameObject, mCellPrefab);
                cell.name = "Cell(clone)";
            }
        }
Пример #6
0
    public static void ExportMusic()
    {
        string sourcePath = HS_Path.CombinePath("Assets", "SubAssets", "Raw", "Music");
        string targetPath = HS_Path.CombinePath("Assets", "SubAssets", "Res", "Prefabs", "Music");

        string[] allAssets = AssetDatabase.FindAssets("t:Object", new string[] { sourcePath });
        for (int i = 0; i < allAssets.Length; i++)
        {
            string    assetPath = AssetDatabase.GUIDToAssetPath(allAssets[i]);
            AudioClip prefab    = AssetDatabase.LoadAssetAtPath <AudioClip>(assetPath);
            if (prefab != null)
            {
                string prefabPath = HS_Path.CombinePath(targetPath, HS_Path.GetFileName(assetPath));
                AssetDatabase.CopyAsset(assetPath, prefabPath);
            }
        }

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        Debug.Log("Done!");
    }
Пример #7
0
        static private void FilterEditorDLL(FilterEditorDLLModel model)
        {
            string rootPath = S_RootPath;

            rootPath = rootPath.Replace("\\", "/");
            string dll     = rootPath + "/Assets/Plugins/HSEngineEditor.dll";
            string destDll = rootPath + "/" + HS_Path.GetFileName(dll);

            if (model == FilterEditorDLLModel.Backups2Assets)
            {
                string temp = destDll;
                destDll = dll;
                dll     = temp;
            }

            if (HS_File.Exists(dll))
            {
                FileUtil.CopyFileOrDirectory(dll, destDll);
                FileUtil.DeleteFileOrDirectory(dll);
                AssetDatabase.Refresh();
            }
        }
Пример #8
0
    public static void SetPackingTagBatch()
    {
        string resPath = HS_Path.CombinePath("Assets", "SubAssets", "Raw", "UI");

        string[] allFolders = AssetDatabase.GetSubFolders(resPath);
        for (int i = 0; i < allFolders.Length; i++)
        {
            string[] pathDatas = HS_Path.SplitPath(allFolders[i]);
            string   tagName   = pathDatas[pathDatas.Length - 1];
            string[] allAssets = AssetDatabase.FindAssets("t:Sprite", new string[] { allFolders[i] });
            for (int j = 0; j < allAssets.Length; j++)
            {
                string          assetPath = AssetDatabase.GUIDToAssetPath(allAssets[j]);
                TextureImporter ti        = TextureImporter.GetAtPath(assetPath) as TextureImporter;
                FormatTexture(ti, tagName);
            }
        }

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        Debug.Log("Done!");
    }