private string GetInfo() { StringBuilder sb = new StringBuilder(); sb.AppendLine("ID: 0x" + _entry.ID.ToString("X8")); sb.AppendLine("Type: " + _entry.Type); sb.AppendLine("Has Header: " + _entry.HasHeader); sb.AppendLine("Has Body: " + _entry.HasBody); List <BundleDependency> dependencies = _entry.GetDependencies(); if (dependencies.Count > 0) { sb.AppendLine("Dependencies[" + dependencies.Count + "] = {"); for (int i = 0; i < dependencies.Count; i++) { BundleDependency bundleDependency = dependencies[i]; sb.AppendLine(" " + bundleDependency.ToString()); } sb.AppendLine("}"); } else { sb.AppendLine("Dependencies[" + dependencies.Count + "];"); } return(sb.ToString()); }
protected virtual async Task <string> ProperJavaScriptDependencyEngine(BundleDependency bundleDependency) { var engine = await FileSystemManager.ReadAsync(Config.BrowserCodeDependencyEngineSourcePath); var startToken = CodeTemplate.DependencyKeyStart.Replace(CodeTemplate.DependencyKey, bundleDependency.DependencyKey); var startIndex = engine.IndexOf(startToken, StringComparison.Ordinal); var endToken = CodeTemplate.DependencyKeyEnd.Replace(CodeTemplate.DependencyKey, bundleDependency.DependencyKey); var endIndex = engine.IndexOf(endToken, StringComparison.Ordinal); var dependencyArray = ""; var dependencyKeyArray = ""; if (!bundleDependency.IsDelete) { foreach (var keyValue in bundleDependency.Dependency) { if (keyValue.Key == null) { dependencyArray += "{ url: '" + keyValue.Value.Replace("~/", "") + "?minversion=" + bundleDependency.Version + "' },"; } else { var depFunc = keyValue.Value.Replace("~/", ""); if (dependencyKeyArray != "") { dependencyKeyArray += ","; } dependencyKeyArray += depFunc.Remove(depFunc.IndexOf(".", StringComparison.Ordinal)) + "()"; } } dependencyArray += "{ url:'" + bundleDependency.Path.Replace("~/", "") + "?minversion=" + bundleDependency.Version + "' }"; } if (startIndex > -1) { engine = engine.Remove(startIndex + startToken.Length, endIndex - (startIndex + startToken.Length)); } if (bundleDependency.IsDelete) { return(engine.Replace(startToken + endToken, "")); } var dependency = CodeTemplate.DependencyTemplate.Replace(CodeTemplate.DependencyKey, bundleDependency.DependencyKey) .Replace(CodeTemplate.DependencyKeyStart, startToken) .Replace(CodeTemplate.DependencyKeyEnd, endToken). Replace(CodeTemplate.DependencyArray, dependencyArray). Replace(CodeTemplate.DependencyKeyArray, dependencyKeyArray); engine = startIndex > -1 ? engine.Replace(startToken + endToken, dependency): engine.Replace(CodeTemplate.NewModule, dependency + " " + System.Environment.NewLine + CodeTemplate.NewModule); return(engine); }
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); }
public BundleDependency CreateBundleDependency(string name) { if (m_mDepends.ContainsKey(name)) { Debug.LogError("createbundle arleady exist:" + name); return(m_mDepends[name]); } BundleDependency bd = new BundleDependency(name); m_mDepends.Add(name, bd); return(bd); }
public virtual async Task <bool> AddOrUpdateDependencyEngineAsync(BundleDependency bundleDependency) { var engine = await ProperJavaScriptDependencyEngine(bundleDependency); await WriteJavaScriptDependencyEngine(Config.BrowserCodeDependencyEngineSourcePath, engine); await WriteJavaScriptDependencyEngine(DependencyEngineDebugPath, engine); if (bundleDependency.IsPublish) { await WriteJavaScriptDependencyEngine(DependencyEngineDisPath, engine); } return(true); }
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(); }
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); }