public override Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader) { if (staticTexGUID == "") return Vector2.zero; Texture2D tex = (Texture2D)loader(guid2Path(staticTexGUID), typeof(Texture2D)); Vector2 size = new Vector2(tex.width * (1f / (_ser_stat_frame_info.scaleFactor.x * 2f)), tex.height * (1f / (_ser_stat_frame_info.scaleFactor.y * 2f))); return size; }
public override Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader) { if (staticTexGUID == "") { return(Vector2.zero); } Texture2D tex = (Texture2D)loader(guid2Path(staticTexGUID), typeof(Texture2D)); Vector2 size = new Vector2(tex.width * (1f / (_ser_stat_frame_info.scaleFactor.x * 2f)), tex.height * (1f / (_ser_stat_frame_info.scaleFactor.y * 2f))); return(size); }
// Collects all textures intended for packing, // as well as sprite frames, together into a // standard form for processing. public virtual void Aggregate(PathFromGUIDDelegate guid2Path, LoadAssetDelegate load, GUIDFromPathDelegate path2Guid) { ArrayList texList = new ArrayList(); ArrayList frameList = new ArrayList(); for (int i = 0; i < States.Length; ++i) { States[i].Allocate(); // First try GUIDs: if (States[i].frameGUIDs.Length >= States[i].framePaths.Length) { for (int j = 0; j < States[i].frameGUIDs.Length; ++j) { string path = guid2Path(States[i].frameGUIDs[j]); texList.Add(load(path, typeof(Texture2D))); frameList.Add(States[i].spriteFrames[j]); } // Make sure we always use GUIDs in the future: States[i].framePaths = new string[0]; } else { States[i].frameGUIDs = new string[States[i].framePaths.Length]; States[i].spriteFrames = new CSpriteFrame[States[i].framePaths.Length]; for (int j = 0; j < States[i].spriteFrames.Length; ++j) { States[i].spriteFrames[j] = new CSpriteFrame(); } for (int j = 0; j < States[i].framePaths.Length; ++j) { // First get a GUID and save it: States[i].frameGUIDs[j] = path2Guid(States[i].framePaths[j]); texList.Add(load(States[i].framePaths[j], typeof(Texture2D))); frameList.Add(States[i].spriteFrames[j]); } } } sourceTextures = (Texture2D[])texList.ToArray(typeof(Texture2D)); spriteFrames = (CSpriteFrame[])frameList.ToArray(typeof(CSpriteFrame)); }
public override Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader) { TextureAnim a = DefaultState; CSpriteFrame f = DefaultFrame; if (a == null) { return(Vector2.zero); } if (a.frameGUIDs == null) { return(Vector2.zero); } if (a.frameGUIDs.Length == 0) { return(Vector2.zero); } if (f == null) { Debug.LogWarning("Sprite \"" + name + "\" does not seem to have been built to an atlas yet."); return(Vector2.zero); } Vector2 size = Vector2.zero; Texture2D tex = (Texture2D)loader(guid2Path(a.frameGUIDs[0]), typeof(Texture2D)); if (tex == null) { if (spriteMesh != null) { tex = (Texture2D)spriteMesh.material.GetTexture("_MainTex"); size = new Vector2(f.uvs.width * tex.width, f.uvs.height * tex.height); } } else { size = new Vector2(tex.width * (1f / (f.scaleFactor.x * 2f)), tex.height * (1f / (f.scaleFactor.y * 2f))); } return(size); }
public override Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader) { TextureAnim defaultState = this.DefaultState; CSpriteFrame defaultFrame = this.DefaultFrame; if (defaultState == null) { return(Vector2.zero); } if (defaultState.frameGUIDs == null) { return(Vector2.zero); } if (defaultState.frameGUIDs.Length == 0) { return(Vector2.zero); } if (defaultFrame == null) { TsLog.LogWarning("Sprite \"" + base.name + "\" does not seem to have been built to an atlas yet.", new object[0]); return(Vector2.zero); } Vector2 zero = Vector2.zero; Texture2D texture2D = (Texture2D)loader(guid2Path(defaultState.frameGUIDs[0]), typeof(Texture2D)); if (texture2D == null) { if (base.spriteMesh != null) { texture2D = (Texture2D)base.spriteMesh.material.GetTexture("_MainTex"); zero = new Vector2(defaultFrame.uvs.width * (float)texture2D.width, defaultFrame.uvs.height * (float)texture2D.height); } } else { zero = new Vector2((float)texture2D.width * (1f / (defaultFrame.scaleFactor.x * 2f)), (float)texture2D.height * (1f / (defaultFrame.scaleFactor.y * 2f))); } return(zero); }
public virtual void Aggregate(PathFromGUIDDelegate guid2Path, LoadAssetDelegate load, GUIDFromPathDelegate path2Guid) { List <Texture2D> list = new List <Texture2D>(); List <CSpriteFrame> list2 = new List <CSpriteFrame>(); for (int i = 0; i < this.States.Length; i++) { this.States[i].Allocate(); if (this.States[i].frameGUIDs.Length >= this.States[i].framePaths.Length) { for (int j = 0; j < this.States[i].frameGUIDs.Length; j++) { string path = guid2Path(this.States[i].frameGUIDs[j]); list.Add((Texture2D)load(path, typeof(Texture2D))); list2.Add(this.States[i].spriteFrames[j]); } this.States[i].framePaths = new string[0]; } else { this.States[i].frameGUIDs = new string[this.States[i].framePaths.Length]; this.States[i].spriteFrames = new CSpriteFrame[this.States[i].framePaths.Length]; for (int k = 0; k < this.States[i].spriteFrames.Length; k++) { this.States[i].spriteFrames[k] = new CSpriteFrame(); } for (int l = 0; l < this.States[i].framePaths.Length; l++) { this.States[i].frameGUIDs[l] = path2Guid(this.States[i].framePaths[l]); list.Add((Texture2D)load(this.States[i].framePaths[l], typeof(Texture2D))); list2.Add(this.States[i].spriteFrames[l]); } } } this.sourceTextures = list.ToArray(); this.spriteFrames = list2.ToArray(); }
protected UVAnimation_Multi curAnim = null; // The current animation public override Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader) { return(pixelDimensions); }
public override Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader) { TextureAnim a = DefaultState; CSpriteFrame f = DefaultFrame; if (a == null) return Vector2.zero; if (a.frameGUIDs == null) return Vector2.zero; if (a.frameGUIDs.Length == 0) return Vector2.zero; if (f == null) { Debug.LogWarning("Sprite \"" + name + "\" does not seem to have been built to an atlas yet."); return Vector2.zero; } Vector2 size = Vector2.zero; Texture2D tex = (Texture2D)loader(guid2Path(a.frameGUIDs[0]), typeof(Texture2D)); if (tex == null) { if (spriteMesh != null) { tex = (Texture2D)spriteMesh.material.GetTexture("_MainTex"); size = new Vector2(f.uvs.width * tex.width, f.uvs.height * tex.height); } } else size = new Vector2(tex.width * (1f / (f.scaleFactor.x * 2f)), tex.height * (1f / (f.scaleFactor.y * 2f))); return size; }
// Collects all textures intended for packing, // as well as sprite frames, together into a // standard form for processing. public virtual void Aggregate(PathFromGUIDDelegate guid2Path, LoadAssetDelegate load, GUIDFromPathDelegate path2Guid) { ArrayList texList = new ArrayList(); ArrayList frameList = new ArrayList(); for (int i = 0; i < States.Length; ++i) { States[i].Allocate(); // First try GUIDs: if (States[i].frameGUIDs.Length >= States[i].framePaths.Length) { for (int j = 0; j < States[i].frameGUIDs.Length; ++j) { string path = guid2Path(States[i].frameGUIDs[j]); texList.Add(load(path, typeof(Texture2D))); frameList.Add(States[i].spriteFrames[j]); } // Make sure we always use GUIDs in the future: States[i].framePaths = new string[0]; } else { States[i].frameGUIDs = new string[States[i].framePaths.Length]; States[i].spriteFrames = new CSpriteFrame[States[i].framePaths.Length]; for (int j = 0; j < States[i].spriteFrames.Length; ++j) States[i].spriteFrames[j] = new CSpriteFrame(); for (int j = 0; j < States[i].framePaths.Length; ++j) { // First get a GUID and save it: States[i].frameGUIDs[j] = path2Guid(States[i].framePaths[j]); texList.Add(load(States[i].framePaths[j], typeof(Texture2D))); frameList.Add(States[i].spriteFrames[j]); } } } sourceTextures = (Texture2D[])texList.ToArray(typeof(Texture2D)); spriteFrames = (CSpriteFrame[])frameList.ToArray(typeof(CSpriteFrame)); }
/// <summary> /// Collects all textures intended for packing, /// as well as sprite frames, together into a /// standard form for processing. /// </summary> public override void Aggregate(PathFromGUIDDelegate guid2Path, LoadAssetDelegate load, GUIDFromPathDelegate path2Guid) { List<Texture2D> texList = new List<Texture2D>(); List<CSpriteFrame> frameList = new List<CSpriteFrame>(); for (int i = 0; i < textureAnimations.Length; ++i) { textureAnimations[i].Allocate(); // First try GUIDs: if (textureAnimations[i].frameGUIDs.Length >= textureAnimations[i].framePaths.Length) { for (int j = 0; j < textureAnimations[i].frameGUIDs.Length; ++j) { string path = guid2Path(textureAnimations[i].frameGUIDs[j]); texList.Add((Texture2D)load(path, typeof(Texture2D))); frameList.Add(textureAnimations[i].spriteFrames[j]); } // Make sure we always use GUIDs in the future: textureAnimations[i].framePaths = new string[0]; } else { textureAnimations[i].frameGUIDs = new string[textureAnimations[i].framePaths.Length]; textureAnimations[i].spriteFrames = new CSpriteFrame[textureAnimations[i].framePaths.Length]; for (int j = 0; j < textureAnimations[i].spriteFrames.Length; ++j) textureAnimations[i].spriteFrames[j] = new CSpriteFrame(); for (int j = 0; j < textureAnimations[i].framePaths.Length; ++j) { if (textureAnimations[i].framePaths[j].Length < 1) continue; // First get a GUID and save it: textureAnimations[i].frameGUIDs[j] = path2Guid(textureAnimations[i].framePaths[j]); texList.Add((Texture2D)load(textureAnimations[i].framePaths[j], typeof(Texture2D))); frameList.Add(textureAnimations[i].spriteFrames[j]); } } } // Get the static frame info: // First try GUID: if(staticTexGUID.Length > 1) { staticTexPath = guid2Path(staticTexGUID); } else // Else, populate the GUID: { staticTexGUID = path2Guid(staticTexPath); } texList.Add((Texture2D)load(staticTexPath, typeof(Texture2D))); frameList.Add(_ser_stat_frame_info); sourceTextures = texList.ToArray(); spriteFrames = frameList.ToArray(); }
// Collects all textures intended for packing, // as well as sprite frames, together into a // standard form for processing. // Receives a delegate reference to AssetDatabase.LoadAssetAtPath public abstract void Aggregate(PathFromGUIDDelegate guid2Path, LoadAssetDelegate load, GUIDFromPathDelegate path2Guid);
public override Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader) { return pixelDimensions; }
public abstract Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader);
/// <summary> /// Collects all textures intended for packing, /// as well as sprite frames, together into a /// standard form for processing. /// </summary> public override void Aggregate(PathFromGUIDDelegate guid2Path, LoadAssetDelegate load, GUIDFromPathDelegate path2Guid) { List <Texture2D> texList = new List <Texture2D>(); List <CSpriteFrame> frameList = new List <CSpriteFrame>(); for (int i = 0; i < textureAnimations.Length; ++i) { textureAnimations[i].Allocate(); // First try GUIDs: if (textureAnimations[i].frameGUIDs.Length >= textureAnimations[i].framePaths.Length) { for (int j = 0; j < textureAnimations[i].frameGUIDs.Length; ++j) { string path = guid2Path(textureAnimations[i].frameGUIDs[j]); texList.Add((Texture2D)load(path, typeof(Texture2D))); frameList.Add(textureAnimations[i].spriteFrames[j]); } // Make sure we always use GUIDs in the future: textureAnimations[i].framePaths = new string[0]; } else { textureAnimations[i].frameGUIDs = new string[textureAnimations[i].framePaths.Length]; textureAnimations[i].spriteFrames = new CSpriteFrame[textureAnimations[i].framePaths.Length]; for (int j = 0; j < textureAnimations[i].spriteFrames.Length; ++j) { textureAnimations[i].spriteFrames[j] = new CSpriteFrame(); } for (int j = 0; j < textureAnimations[i].framePaths.Length; ++j) { if (textureAnimations[i].framePaths[j].Length < 1) { continue; } // First get a GUID and save it: textureAnimations[i].frameGUIDs[j] = path2Guid(textureAnimations[i].framePaths[j]); texList.Add((Texture2D)load(textureAnimations[i].framePaths[j], typeof(Texture2D))); frameList.Add(textureAnimations[i].spriteFrames[j]); } } } // Get the static frame info: // First try GUID: if (staticTexGUID.Length > 1) { staticTexPath = guid2Path(staticTexGUID); } else // Else, populate the GUID: { staticTexGUID = path2Guid(staticTexPath); } texList.Add((Texture2D)load(staticTexPath, typeof(Texture2D))); frameList.Add(_ser_stat_frame_info); sourceTextures = texList.ToArray(); spriteFrames = frameList.ToArray(); }
public Vector2 GetDefaultPixelSize(PathFromGUIDDelegate guid2Path, AssetLoaderDelegate loader) { Vector2 size = Vector2.zero; return(size); }