예제 #1
0
    public void UIAssetImport()
    {
        string DynamicUIPath = Application.dataPath + AssetBundleImporter.UIDynamicAssetPatch.Remove(0, AssetBundleImporter.UIDynamicAssetPatch.IndexOf('/'));

        if (Directory.Exists(DynamicUIPath))
        {
            DirectoryInfo fromDirInfo = new DirectoryInfo(DynamicUIPath);
            FileInfo[]    allPngFiles = fromDirInfo.GetFiles("*.png", SearchOption.AllDirectories);

            m_ConfigTable.Clear();

            string tmpPath = string.Empty;

            foreach (var files in allPngFiles)
            {
                tmpPath = files.FullName.Remove(0, files.FullName.IndexOf("Assets"));
                UFileData data = new UFileData();
                data.configData = AssetBundleImporter.MakeTextureAssetBundleFromReference(tmpPath, string.Empty);
                if (null != data.configData)
                {
                    PostprocessUITextureToCSV.nEditorInstance.InsetConfig(data);
                }
                else
                {
                    Debug.LogError("取得UI资源失败:" + tmpPath);
                    continue;
                }
            }

            PostprocessUITextureToCSV.nEditorInstance.ExportConfig();
        }
    }
예제 #2
0
    void DrawSelectedFolderAllFiles()
    {
        int index = 0;

        Vector2 IconSize = CalIconSize(true);

        int horiCound = (int)(SelectedDataRect.width / IconSize.x) - 1;

        horiCound = horiCound == 0 ? 1 : horiCound;

        EditorGUIUtility.SetIconSize(IconSize);

        for (int i = 0; i < AreaSelectedData.childs.Count; i += horiCound)
        {
            GUILayout.BeginHorizontal();
            for (int j = 0; j < horiCound; j++)
            {
                index = i + j;
                if ((index < AreaSelectedData.childs.Count) &&
                    GUILayout.Button(AreaSelectedData.childs[index].content.image, GUILayout.Width(IconSize.x), GUILayout.Height(IconSize.y)))
                {
                    CurrentSelectedData = AreaSelectedData.childs[index];
                    Debug.Log("selectedData::" + AreaSelectedData.childs[index].assetPath);
                }
            }
            GUILayout.EndHorizontal();
        }
    }
예제 #3
0
    public void InsetConfig(UFileData data)
    {
        if (!data.configData.AssetBundleName.Equals(string.Empty))
        {
            //包名已经存在了
            if (m_ConfigTable.ContainsKey(data.configData.AssetBundleName))
            {
                Dictionary <string, UFileData> ta = m_ConfigTable[data.configData.AssetBundleName];
                if (ta.ContainsKey(data.configData.AssetName))
                {
                    ta[data.configData.AssetName] = data;
                    return;
                }
                ta.Add(data.configData.AssetName, data);
            }
            else
            {
                Dictionary <string, UFileData> ta = new Dictionary <string, UFileData>();
                ta.Add(data.configData.AssetName, data);
                m_ConfigTable.Add(data.configData.AssetBundleName, ta);
            }
        }

        //EditorUtility.SetDirty(this);
    }
예제 #4
0
    private void ImportBin()
    {
        string patch = AssetBundleManager.GetUIBinConfigPatch();

        if (!File.Exists(patch))
        {
            return;
        }

        m_ConfigTable.Clear();
        FileStream _readObj = null;

        _readObj = new FileStream(patch, FileMode.Open, FileAccess.Read);

        int cout = 0;

        AssetBundleManager.ReadStruct(ref cout, _readObj);

        if (cout <= 0)
        {
            return;
        }

        // 遍歷整個表并存儲起來
        for (int i = 0; i < cout; ++i)
        {
            UFileData data = new UFileData();

            data.configData.AssetBundleName = AssetBundleManager.ReadString(_readObj);
            data.configData.AssetName       = AssetBundleManager.ReadString(_readObj);
            data.configData.AssetGUID       = AssetBundleManager.ReadString(_readObj);
            data.configData.AssetSize_X     = float.TryParse(AssetBundleManager.ReadString(_readObj), out data.configData.AssetSize_X) ? data.configData.AssetSize_X : -1;
            data.configData.AssetSize_Y     = float.TryParse(AssetBundleManager.ReadString(_readObj), out data.configData.AssetSize_Y) ? data.configData.AssetSize_Y : -1;

            //包名已经存在了
            if (m_ConfigTable.ContainsKey(data.configData.AssetBundleName))
            {
                Dictionary <string, UFileData> ta = m_ConfigTable[data.configData.AssetBundleName];
                if (ta.ContainsKey(data.configData.AssetName))
                {
                    Debug.LogError("重复的资源名:" + data.configData.AssetName + ",包:" + data.configData.AssetBundleName);
                    continue;
                }
                ta.Add(data.configData.AssetName, data);
            }
            else
            {
                Dictionary <string, UFileData> ta = new Dictionary <string, UFileData>();
                ta.Add(data.configData.AssetName, data);
                m_ConfigTable.Add(data.configData.AssetBundleName, ta);
            }
        }

        _readObj.Flush();
        _readObj.Close();
        _readObj = null;
    }
예제 #5
0
    void DrawSelectedFile()
    {
        Vector2 IconSize = CalIconSize(false);

        EditorGUIUtility.SetIconSize(IconSize);
        if (GUILayout.Button(AreaSelectedData.content.image, GUILayout.Width(IconSize.x), GUILayout.Height(IconSize.y)))
        {
            CurrentSelectedData = AreaSelectedData;
            Debug.Log("selectedData::" + AreaSelectedData.assetPath);
        }
    }
예제 #6
0
 void GenrateConfigID(UFileData da)
 {
     if (da.childs.Count <= 0)
     {
         UImageInformationEditorWindow.nEditorInstance.InsetConfig(da);
         return;
     }
     foreach (UFileData d in da.childs)
     {
         GenrateConfigID(d);
     }
 }
예제 #7
0
    private void ImportCSV()
    {
        string patch = AssetBundleManager.GetUICSVConfigPatch();

        if (!File.Exists(patch))
        {
            return;
        }
        m_ConfigTable.Clear();
        string stSchemeAllText = System.IO.File.ReadAllText(patch);

        //去掉\n,因为ScpReader以"\r"分割
        stSchemeAllText = stSchemeAllText.Replace("\n", "");
        //再干掉最后的"\r"
        stSchemeAllText = stSchemeAllText.Remove(stSchemeAllText.Length - 1, 1);
        ScpReader UIReader = new ScpReader(stSchemeAllText, "UIConfig", 2);

        // 遍歷整個表并存儲起來
        for (int i = 0; i < UIReader.GetRecordCount(); ++i)
        {
            UFileData data = new UFileData();
            //data.packageID = UIReader.GetInt(i, (int)AssetBundleManager.UIConfigCol.COL_ID, -1);
            data.configData.AssetBundleName = UIReader.GetString(i, (int)AssetBundleManager.AssetConfigCol.COL_AssetBundleName, "");
            data.configData.AssetName       = UIReader.GetString(i, (int)AssetBundleManager.AssetConfigCol.COL_AssetName, "");
            data.configData.AssetBundleName = UIReader.GetString(i, (int)AssetBundleManager.AssetConfigCol.COL_AssetGUID, "");
            data.configData.AssetSize_X     = UIReader.GetFloat(i, (int)AssetBundleManager.AssetConfigCol.COL_AssetSize_X, -1);
            data.configData.AssetSize_Y     = UIReader.GetFloat(i, (int)AssetBundleManager.AssetConfigCol.COL_AssetSize_Y, -1);
            //包名已经存在了
            if (m_ConfigTable.ContainsKey(data.configData.AssetBundleName))
            {
                Dictionary <string, UFileData> ta = m_ConfigTable[data.configData.AssetBundleName];
                if (ta.ContainsKey(data.configData.AssetName))
                {
                    Debug.LogError("重复的资源名:" + data.configData.AssetName + ",包:" + data.configData.AssetBundleName);
                    continue;
                }
                ta.Add(data.configData.AssetName, data);
            }
            else
            {
                Dictionary <string, UFileData> ta = new Dictionary <string, UFileData>();
                ta.Add(data.configData.AssetName, data);
                m_ConfigTable.Add(data.configData.AssetBundleName, ta);
            }
        }
        UIReader.Dispose();
        UIReader = null;
    }
예제 #8
0
    public void OnEnable()
    {
        if (target != null && Directory.Exists(AssetDatabase.GetAssetPath(target)))
        {
            string activeObjectPath = AssetDatabase.GetAssetPath(Selection.activeObject);
            //选中路径为 Assets/Artist/UI/Dynamic 路径下的才会有效,其余的目前没必要
            string DynamicPath = UPostprocessTexture.UIRootPath + UPostprocessTexture.PathConnectionSymbol + UPostprocessTexture.DynamicPath;
            if (!activeObjectPath.Contains(DynamicPath))
            {
                return;
            }

            data = new UFileData();
            UImageInformationEditorWindow.nEditorInstance.LoadFiles(data, activeObjectPath);

            UImageInformationEditorWindow.nEditorInstance.TreeSelectData = data;
            //GenrateConfigID(data);
        }
    }
예제 #9
0
 public void InsetConfig(UFileData data)
 {
     if (!data.configData.AssetBundleName.Equals(string.Empty))
     {
         data.packageID = GetID(data.configData.AssetBundleName);
         //包名已经存在了
         if (m_ConfigTable.ContainsKey(data.configData.AssetBundleName))
         {
             Dictionary <string, UFileData> ta = m_ConfigTable[data.configData.AssetBundleName];
             if (ta.ContainsKey(data.configData.AssetName))
             {
                 return;
             }
             ta.Add(data.configData.AssetName, data);
         }
         else
         {
             Dictionary <string, UFileData> ta = new Dictionary <string, UFileData>();
             ta.Add(data.configData.AssetName, data);
             m_ConfigTable.Add(data.configData.AssetBundleName, ta);
         }
     }
 }
예제 #10
0
    void DrawGUIData(UFileData data)
    {
        GUIStyle style = "Label";

        Rect rt = GUILayoutUtility.GetRect(data.content, style);

        if (data.isSelected)
        {
            EditorGUI.DrawRect(rt, Color.gray);
        }

        rt.x += (16 * EditorGUI.indentLevel);
        if (GUI.Button(rt, data.content, style))
        {
            if (AreaSelectedData != null)
            {
                AreaSelectedData.isSelected = false;
            }
            data.isSelected     = true;
            CurrentSelectedData = AreaSelectedData = data;
            Debug.Log(data.assetPath);
        }
    }
예제 #11
0
 void DrawData(UFileData data)
 {
     if (data.content != null)
     {
         EditorGUI.indentLevel = data.depth;
         DrawGUIData(data);
     }
     for (int i = 0; i < data.childs.Count; i++)
     {
         UFileData child = data.childs[i];
         if (child.content != null)
         {
             EditorGUI.indentLevel = child.depth;
             if (child.childs.Count > 0)
             {
                 DrawData(child);
             }
             else
             {
                 DrawGUIData(child);
             }
         }
     }
 }
예제 #12
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        bool bMovedSound  = false;
        bool bImportSound = false;

        //处理的是否是UI文件
        bool bImportUI = false;


        OnPreProcessScheme();

        for (int i = 0; i < importedAssets.Length; i++)
        {
            //看看是不是场景文件
            string s = importedAssets[i];
            AssetBundleManagerEditor.CheckAssetName(s);
            if (isSceneAssets(s))
            {
                MakeSceneAssetBundleInfo(s);
            }
            else if (isShaderAssets(s))
            {
                MakeShaderAssetBundle(s);
            }
            else if (isMeshAssets(s))
            {
                MakeMeshAssetBundle(s);
            }
            else if (isAudioAssets(s))
            {
                bImportSound = true;
                MakeSoundAssetBundleData(s);
            }
            else if (IsFontAsset(s))
            {
                MakeFontBundleData(AssetImporter.GetAtPath(s));
            }
            else if (IsFBXAsset(s))
            {
                MakeFBXAssetBundle(AssetImporter.GetAtPath(s) as ModelImporter);
            }
            else if (IsMaterialAsset(s))
            {
                MakeMaterialAssetBundle(s);
            }
            else if (IsAniClipAsset(s))
            {
                MakeAnimatorClipAssetBundleData(s);
            }
            else if (IsControllerAsset(s))
            {
                MakeAnimatorControllerAssetBundleData(s);
            }
            else if (IsTextureAsset(s))
            {
                MakeTextureAssetBundle(s);
            }
            else if (isSchemeAssets(s))
            {
                MakeSchemeAssetBundleInfo(s);
            }

            string path = importedAssets[i];
            //载入的话弄到表里
            if (path.Contains(UIDynamicAssetPatch))
            {
                if (!IsTextureAsset(path))
                {
                    continue;
                }

                bImportUI = true;
                UFileData data = new UFileData();

                data.configData = MakeTextureAssetBundleFromReference(path, string.Empty);
                if (null != data.configData)
                {
                    PostprocessUITextureToCSV.nEditorInstance.InsetConfig(data);
                }
                else
                {
                    Debug.LogError("取得UI资源失败:" + path);
                }
            }
        }

        //资源移动了
        List <string> movedGUID = new List <string>();

        for (int i = 0; i < movedAssets.Length; i++)
        {
            string str = movedAssets[i];
            AssetBundleManagerEditor.CheckAssetName(movedAssets[i]);
            //先清掉ab
            ClearAssetBundleData(AssetImporter.GetAtPath(str));

            //再根据资源类型来重新生成ab
            //是音效的
            if (isAudioAssets(str))
            {
                MakeSoundAssetBundleData(str);
                movedGUID.Add(AssetBundleManagerEditor.GetAssetGUIDFromMeta(str));
                bMovedSound = true;
            }
            //是贴图
            else if (IsTextureAsset(str))
            {
                MakeTextureAssetBundle(str);
            }
            //是场景
            else if (isSceneAssets(str))
            {
                MakeSceneAssetBundleInfo(str);
            }
            else if (IsFontAsset(str))
            {
                MakeFontBundleData(AssetImporter.GetAtPath(str));
            }
            else if (IsFBXAsset(str))
            {
                CheckFBXInImportTime(str);
                MakeFBXAssetBundle(AssetImporter.GetAtPath(str) as ModelImporter);
            }
            else if (IsMaterialAsset(str))
            {
                MakeMaterialAssetBundle(str);
            }
            else if (IsAniClipAsset(str))
            {
                MakeAnimatorClipAssetBundleData(str);
            }
            else if (IsControllerAsset(str))
            {
                MakeAnimatorControllerAssetBundleData(str);
            }
            else if (isSchemeAssets(str))
            {
                MakeSchemeAssetBundleInfo(str);
            }
            else if (isShaderAssets(str))
            {
                MakeShaderAssetBundle(str);
            }
            else if (isMeshAssets(str))
            {
                MakeMeshAssetBundle(str);
            }
            string path = movedAssets[i];
            if (path.Contains(UIDynamicAssetPatch))
            {
                bImportUI = true;
                AssetImporter assetImporter = AssetImporter.GetAtPath(path);

                PostprocessUITextureToCSV.nEditorInstance.RemoveConfig(PostprocessUITextureToCSV.GetGUID(assetImporter.assetPath));
            }
        }

        if (SoundSystem.SoundSystemEditorWindow.EditorInstance)
        {
            if (bMovedSound || bImportSound)
            {
                if (bMovedSound)
                {
                    SoundSystem.SoundSystemEditorWindow.RefrshAudioClipSource(movedGUID);
                }
                else
                {
                    SoundSystem.SoundSystemEditorWindow.RefrshAudioClipSource();
                }
            }
        }

        //UI的处理完保存配置
        if (bImportUI)
        {
            PostprocessUITextureToCSV.nEditorInstance.ExportConfig();
        }

        OnPostProcessScheme();

        if (!AssetBundleManagerEditor.isBuildingPackage && !AssetBundleManagerEditor.isCleaningAssets)
        {
            AssetBundleManager.LoadPrefabConfig();

            for (int i = 0; i < movedAssets.Length; i++)
            {
                string str = movedAssets[i];
                if (IsPrefabAssets(movedFromAssetPaths[i]))
                {
                    ClearSinglePrefab(str);
                }

                if (IsPrefabAssets(str))
                {
                    ImportSinglePrefab(str, true);
                }
            }


            for (int i = 0; i < importedAssets.Length; i++)
            {
                ImportSinglePrefab(importedAssets[i], true);
            }

            SchemeExport.Export_PrefabScheme();
            AssetBundleManager.ClearPrefabConfig();
        }


        //进入播放模式的时候会调用一次这个postallasets,所以要加载一次配置
        if (Application.isPlaying)
        {
            AssetBundleManager.LoadPrefabConfig();
        }

        if (movedAssets.Length > 0)
        {
            AssetDatabase.Refresh();
        }
        //移除无用的ab名
        AssetDatabase.RemoveUnusedAssetBundleNames();
    }
예제 #13
0
    public void LoadFiles(UFileData data, string currentPath, int depth = 0)
    {
        GUIContent content = GetGUIContent(currentPath);

        if (content != null)
        {
            data.depth   = depth;
            data.content = content;
            string patch1 = currentPath.Replace("\\", "/");
            data.assetPath = patch1;
            if (patch1.Contains('.'))
            {
                ResConfigData config = AssetBundleImporter.MakeTextureAssetBundleFromReference(patch1, string.Empty);
                if (null == config)
                {
                    Debug.LogError("找不资源的,资源路径:" + patch1);
                }
                data.configData = config;
            }
        }
        //当前路径下所有文件信息
        foreach (var path in Directory.GetFiles(currentPath))
        {
            content = GetGUIContent(path);
            if (content != null)
            {
                UFileData child = new UFileData();
                child.depth   = depth + 1;
                child.content = content;
                string patch1 = path.Replace("\\", "/");
                child.assetPath = patch1;
                if (patch1.Contains('.'))
                {
                    ResConfigData config = AssetBundleImporter.MakeTextureAssetBundleFromReference(patch1, string.Empty);
                    if (null == config)
                    {
                        Debug.LogError("找不资源的,资源路径:" + patch1);
                    }
                    child.configData = config;
                }
                data.childs.Add(child);
            }
        }

        //WillTodo:排序这里无法判断没ID的图片,先不用
        //data.childs.Sort((x, y) =>
        //{
        //    UFileData XData = x as UFileData;
        //    UFileData YData = y as UFileData;
        //    int idX = Convert.ToInt32(XData.assetPath.Substring(XData.assetPath.LastIndexOf('_') + 1, XData.assetPath.LastIndexOf('.') - XData.assetPath.LastIndexOf('_') - 1));
        //    int idY = Convert.ToInt32(YData.assetPath.Substring(YData.assetPath.LastIndexOf('_') + 1, YData.assetPath.LastIndexOf('.') - YData.assetPath.LastIndexOf('_') - 1));

        //    return idX.CompareTo(idY);

        //});

        foreach (var path in Directory.GetDirectories(currentPath))
        {
            UFileData childDir = new UFileData();
            data.childs.Add(childDir);
            LoadFiles(childDir, path, depth + 1);
        }
    }