Example #1
0
    public bool CheckMd5UIMapDirty(string bundleName, string mapName, string path, string[] deps = null)
    {
        EditorApplication.OpenScene(path);
        GameObject scene = GameObject.Find(mapName);

        if (scene)
        {
            BundleDependency bd = CreateBundleDependency(bundleName);

            List <BundleDependency> depends = new List <BundleDependency>();
            if (deps != null)
            {
                foreach (string d in deps)
                {
                    if (m_mDepends.ContainsKey(d))
                    {
                        depends.Add(m_mDepends[d]);
                    }
                }
            }

            Object[] objs = new Object[1] {
                scene
            };

            //dependency
            Object[] rets = EditorUtility.CollectDependencies(objs);
            //Debug.Log("rets:" + rets.Length);
            foreach (Object oc in rets)
            {
                //Debug.Log("dep:" + oc.ToString());
                string s = AssetDatabase.GetAssetPath(oc);
                bd.AddFileName(s, depends);
                //Debug.Log("path:" + s);
            }

            bd.AddFileName(path, depends);

            //Debug.Log("result:" + mapName + bd.GetDirty().ToString());
            if (bd.GetDirty())
            {
                bd.PrintDirtyFile();
                return(true);
            }
        }
        else
        {
            return(true);

            Debug.LogError("cant find uimap obj in " + mapName);
        }
        return(false);
    }
Example #2
0
    public bool CheckMd5PrefabDirty(string name, Object[] objs, string[] deps = null)
    {
        BundleDependency        bd      = CreateBundleDependency(name);
        List <BundleDependency> depends = new List <BundleDependency>();

        if (deps != null)
        {
            foreach (string d in deps)
            {
                if (m_mDepends.ContainsKey(d))
                {
                    depends.Add(m_mDepends[d]);
                }
            }
        }


        List <string> paths = new List <string>();

        foreach (Object obj in objs)
        {
            string path = AssetDatabase.GetAssetPath(obj);
            paths.Add(path);

            //self arealdy in dependency
            //bd.AddFileName(path);
        }


        //dependency
        string[] ss = AssetDatabase.GetDependencies(paths.ToArray());
        //Debug.Log("ss:" + ss.Length);
        foreach (string s in ss)
        {
            bd.AddFileName(s, depends);
            //Debug.Log("chpath:" + s);
        }

        Debug.Log("result:" + name + bd.GetDirty().ToString());
        if (bd.GetDirty())
        {
            bd.PrintDirtyFile();
            return(true);
        }

        return(false);
    }
    public void test()
    {
        Md5Manager.Instance.Start();
        string mapName = "Town_01";
        string mapPath = "Map/" + mapName + ".unity";
        string path    = Path.Combine(Application.dataPath, mapPath);

        EditorApplication.OpenScene(path);
        GameObject scene = GameObject.Find("Scene");

        if (scene)
        {
            BundleDependency bd   = Md5Manager.Instance.CreateBundleDependency(mapName);
            Object[]         objs = new Object[1] {
                scene
            };

            //dependency
            Object[] rets = EditorUtility.CollectDependencies(objs);
            Debug.Log("rets:" + rets.Length);
            foreach (Object oc in rets)
            {
                Debug.Log("dep:" + oc.ToString());
                string s = AssetDatabase.GetAssetPath(oc);
                bd.AddFileName(s);
                Debug.Log("path:" + s);
            }

            //child prefab
            Transform[] trans = scene.GetComponentsInChildren <Transform>();
            foreach (Transform t in trans)
            {
                GameObject child = t.gameObject;
                if (PrefabType.None == EditorUtility.GetPrefabType(child))
                {
                    continue;
                }
                if ((Object)child != EditorUtility.FindPrefabRoot(child))
                {
                    continue;
                }
                Debug.Log("prefab:" + child.ToString());
                string s = AssetDatabase.GetAssetPath(EditorUtility.GetPrefabParent(child));
                bd.AddFileName(s);
                Debug.Log("prefabPath:" + s);
            }
            bd.AddFileName(path);
            List <string> assets       = new List <string>();
            string        lightMapPath = Path.Combine(Application.dataPath, "Map/" + mapName);
            BuildAssetStruct.GetAllAssetsString(lightMapPath, assets, true);
            foreach (string s in assets)
            {
                bd.AddFileName(s);
            }
            Debug.Log("result:" + mapName + bd.GetDirty().ToString());
            bd.PrintDirtyFile();
        }


        Md5Manager.Instance.CheckVerion();
        Md5Manager.Instance.End();
    }
Example #4
0
    public bool CheckMd5SceneDirty(string mapName, string path)
    {
        EditorApplication.OpenScene(path);
        GameObject scene  = GameObject.Find("Scene");
        GameObject camera = GameObject.Find("Main Camera");

        if (scene && camera)
        {
            BundleDependency bd = CreateBundleDependency(mapName);

            //dependency
            Object[] objs = new Object[2] {
                scene, camera
            };
            Object[] rets = EditorUtility.CollectDependencies(objs);
            //Debug.Log("rets:" + rets.Length);
            foreach (Object oc in rets)
            {
                //Debug.Log("dep:" + oc.ToString());
                string s = AssetDatabase.GetAssetPath(oc);
                bd.AddFileName(s);
                //Debug.Log("path:" + s);
            }

            //child prefab
            Transform[] trans = scene.GetComponentsInChildren <Transform>();
            foreach (Transform t in trans)
            {
                GameObject child = t.gameObject;
                if (PrefabType.None == EditorUtility.GetPrefabType(child))
                {
                    continue;
                }
                if ((Object)child != EditorUtility.FindPrefabRoot(child))
                {
                    continue;
                }
                //Debug.Log("prefab:" + child.ToString());
                string s = AssetDatabase.GetAssetPath(EditorUtility.GetPrefabParent(child));
                bd.AddFileName(s);
                //Debug.Log("prefabPath:" + s);
            }

            //bd.AddFileName(path);
            //List<string> assets = new List<string>();
            //string lightMapPath = Path.Combine(Application.dataPath, "Map/" + mapName);
            //BuildAssetStruct.GetAllAssetsString(lightMapPath, assets, true);
            //foreach(string s in assets)
            //{
            //    bd.AddFileName(s);
            //}
            //Debug.Log("result:" + mapName + bd.GetDirty().ToString());
            if (bd.GetDirty())
            {
                bd.PrintDirtyFile();
                return(true);
            }
        }
        else
        {
            return(true);

            Debug.LogError("cant find scene or camera obj in " + mapName);
        }
        return(false);
    }