UIAtlas getAtlasByName(string atlasName) { string tmpPath = PStr.begin() .a("Assets/").a(CLPathCfg.self.basePath).a("/").a("upgradeRes4Dev"). a("/priority/atlas/").a(atlasName).a(".prefab").end(); UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(tmpPath, typeof(UnityEngine.Object)); if (obj != null) { return(((GameObject)obj).GetComponent <UIAtlas> ()); } return(null); }
// private InstanceAnimationInfo CreateAnimationInfoFromFile(GameObject prefab) // { // Debug.Assert(prefab != null); // string path; //#if UNITY_EDITOR || UNITY_STANDALONE_WIN // path = Application.dataPath + "/AnimationTexture/"; //#elif UNITY_STANDALONE_OSX // path = Application.dataPath + "/Resources/Data/StreamingAssets/AnimationTexture/"; //#endif // //#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX // //Debug.Log("This is the data path:" + path); // FileStream file = File.Open(path + prefab.name + ".bytes", FileMode.Open); // Debug.Assert(file.CanRead); // InstanceAnimationInfo info = new InstanceAnimationInfo(); // BinaryReader reader = new BinaryReader(file); // info.listAniInfo = ReadAnimationInfo(reader); // info.extraBoneInfo = ReadExtraBoneInfo(reader); // m_animationInfo.Add(prefab, info); // AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader); // file.Close(); //#elif UNITY_IPHONE // path = "file://" + Application.dataPath +"/Raw/AnimationTexture/"; // WWW w = new WWW(path + prefab.name + ".bytes"); // //wwwLoad(path + "/boneTexture/" + prefab.name + ".aniData", SetupAniInfo); // while (!w.isDone){} // //if (w.error) // Debug.Log("This is the data path:" + path); // Debug.Log(w.error); // BinaryReader reader = new BinaryReader(new MemoryStream(w.bytes)); // InstanceAnimationInfo info = new InstanceAnimationInfo(); // info.listAniInfo = ReadAnimationInfo(reader); // info.extraBoneInfo = ReadExtraBoneInfo(reader); // m_animationInfo.Add(prefab, info); // AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader); //#elif UNITY_ANDROID // path = "jar:file://" + Application.dataPath + "!/assets/"; // WWW w = new WWW(path + "AnimationTexture/" + prefab.name + ".bytes"); // //wwwLoad(path + "/boneTexture/" + thisPrefab.name + ".aniData", SetupAniInfo); // while (!w.isDone) { } //// BinaryReader reader = new BinaryReader(new MemoryStream(w.bytes)); //// List<AnimationInfo> listInfo = ReadAnimationInfo(reader); //// m_animationInfo.Add(prefab, listInfo); // BinaryReader reader = new BinaryReader(new MemoryStream(w.bytes)); // InstanceAnimationInfo info = new InstanceAnimationInfo(); // info.listAniInfo = ReadAnimationInfo(reader); // info.extraBoneInfo = ReadExtraBoneInfo(reader); // m_animationInfo.Add(prefab, info); // AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader); //#endif // return info; // } public InstanceAnimationInfo CreateAnimationInfoFromFile(string cfgName, string prefabName = null) { prefabName = cfgName; string tmpPath = PStr.begin().a(CLPathCfg.self.basePath).a("/").a("upgradeRes"). a("/priority/AnimationTexture/").a(CLPathCfg.self.platform).a("/").a(prefabName).a(".unity3d").end(); #if UNITY_EDITOR if (CLCfgBase.self.isEditMode) { tmpPath = tmpPath.Replace("/upgradeRes/", "/upgradeRes4Publish/"); } #endif AssetBundle assetBundel = AssetBundle.LoadFromMemory(FileEx.readNewAllBytes(tmpPath)); // Debug.Assert(assetBundel != null); if (assetBundel == null) { Debug.LogError("assetBundel == null"); return(null); } TextAsset asset = assetBundel.LoadAsset(cfgName) as TextAsset; // TextAsset asset = assetBundel.mainAsset as TextAsset; // Debug.Assert(asset != null); if (asset == null) { Debug.LogError("asset == null"); return(null); } BinaryReader reader = new BinaryReader(new MemoryStream(asset.bytes)); InstanceAnimationInfo info = new InstanceAnimationInfo(); info.listAniInfo = ReadAnimationInfo(reader); info.extraBoneInfo = ReadExtraBoneInfo(reader); AnimationInstancingMgr.Instance.ImportAnimationTexture(prefabName, reader); m_animationInfo.Add(prefabName, info); assetBundel.Unload(false); return(info); }