public void SetAnim(TextureAnim anim, int idx) { if (anim == null) { return; } if (anim.spriteFrames == null) { return; } this.frames = new SPRITE_FRAME[anim.spriteFrames.Length]; this.index = idx; this.name = anim.name; this.loopCycles = anim.loopCycles; this.loopReverse = anim.loopReverse; this.framerate = anim.framerate; this.onAnimEnd = anim.onAnimEnd; try { for (int i = 0; i < this.frames.Length; i++) { this.frames[i] = anim.spriteFrames[i].ToStruct(); } } catch (Exception ex) { TsLog.LogError("Exception caught in UVAnimation.SetAnim(). Make sure you have re-built your atlases!\nException: " + ex.Message, new object[0]); } this.CalcLength(); }
public override int GetHashCode() { return ((Flexible != null ? Flexible.GetHashCode() : 0) ^ (Light != null ? Light.GetHashCode() : 0) ^ (Sculpt != null ? Sculpt.GetHashCode() : 0) ^ PrimData.Material.GetHashCode() ^ //TODO: NameValues? PrimData.PathBegin.GetHashCode() ^ PrimData.PathCurve.GetHashCode() ^ PrimData.PathEnd.GetHashCode() ^ PrimData.PathRadiusOffset.GetHashCode() ^ PrimData.PathRevolutions.GetHashCode() ^ PrimData.PathScaleX.GetHashCode() ^ PrimData.PathScaleY.GetHashCode() ^ PrimData.PathShearX.GetHashCode() ^ PrimData.PathShearY.GetHashCode() ^ PrimData.PathSkew.GetHashCode() ^ PrimData.PathTaperX.GetHashCode() ^ PrimData.PathTaperY.GetHashCode() ^ PrimData.PathTwist.GetHashCode() ^ PrimData.PathTwistBegin.GetHashCode() ^ PrimData.PCode.GetHashCode() ^ PrimData.ProfileBegin.GetHashCode() ^ PrimData.ProfileCurve.GetHashCode() ^ PrimData.ProfileEnd.GetHashCode() ^ PrimData.ProfileHollow.GetHashCode() ^ TextureAnim.GetHashCode() ^ (Textures != null ? Textures.GetHashCode() : 0) ^ PrimData.State.GetHashCode()); }
/// <summary> /// Copies all the attributes of another sprite, /// including its edit-time TextureAnimations. /// </summary> /// <param name="s">A reference to the sprite to be copied.</param> public virtual void CopyAll(SpriteRoot s) { AutoSpriteBase sp; base.Copy(s); // Check the type: if (!(s is AutoSpriteBase)) { return; } sp = (AutoSpriteBase)s; States = new TextureAnim[sp.States.Length]; for (int i = 0; i < States.Length; ++i) { States[i] = new TextureAnim(); States[i].Copy(sp.States[i]); } animations = new UVAnimation[States.Length]; for (int i = 0; i < States.Length; ++i) { animations[i] = new UVAnimation(); animations[i].SetAnim(States[i], i); } }
public void ReadFromFile(BinaryReader reader) { fileHash = reader.ReadUInt64(); fileName = Functions.ReadString16(reader); unk0 = reader.ReadInt32(); textureCount = reader.ReadInt32(); textures = new TextureAnim[textureCount]; for (int i = 0; i != textureCount; i++) { textures[i] = new TextureAnim(reader); } }
protected override void Awake() { if (TextureAnimations == null) { TextureAnimations = new TextureAnim[0]; } staticFrameInfo = _ser_stat_frame_info.ToStruct(); base.Awake(); Init(); }
public override int GetHashCode() { return (Position.GetHashCode() ^ Velocity.GetHashCode() ^ Acceleration.GetHashCode() ^ Rotation.GetHashCode() ^ AngularVelocity.GetHashCode() ^ ClickAction.GetHashCode() ^ (Flexible != null ? Flexible.GetHashCode() : 0) ^ (Light != null ? Light.GetHashCode() : 0) ^ (Sculpt != null ? Sculpt.GetHashCode() : 0) ^ Flags.GetHashCode() ^ PrimData.Material.GetHashCode() ^ MediaURL.GetHashCode() ^ //TODO: NameValues? (Properties != null ? Properties.OwnerID.GetHashCode() : 0) ^ ParentID.GetHashCode() ^ PrimData.PathBegin.GetHashCode() ^ PrimData.PathCurve.GetHashCode() ^ PrimData.PathEnd.GetHashCode() ^ PrimData.PathRadiusOffset.GetHashCode() ^ PrimData.PathRevolutions.GetHashCode() ^ PrimData.PathScaleX.GetHashCode() ^ PrimData.PathScaleY.GetHashCode() ^ PrimData.PathShearX.GetHashCode() ^ PrimData.PathShearY.GetHashCode() ^ PrimData.PathSkew.GetHashCode() ^ PrimData.PathTaperX.GetHashCode() ^ PrimData.PathTaperY.GetHashCode() ^ PrimData.PathTwist.GetHashCode() ^ PrimData.PathTwistBegin.GetHashCode() ^ PrimData.PCode.GetHashCode() ^ PrimData.ProfileBegin.GetHashCode() ^ PrimData.ProfileCurve.GetHashCode() ^ PrimData.ProfileEnd.GetHashCode() ^ PrimData.ProfileHollow.GetHashCode() ^ ParticleSys.GetHashCode() ^ TextColor.GetHashCode() ^ TextureAnim.GetHashCode() ^ (Textures != null ? Textures.GetHashCode() : 0) ^ SoundRadius.GetHashCode() ^ Scale.GetHashCode() ^ Sound.GetHashCode() ^ PrimData.State.GetHashCode() ^ Text.GetHashCode() ^ TreeSpecies.GetHashCode()); }
public void Copy(TextureAnim a) { this.name = a.name; this.loopCycles = a.loopCycles; this.loopReverse = a.loopReverse; this.framerate = a.framerate; this.onAnimEnd = a.onAnimEnd; this.framePaths = new string[a.framePaths.Length]; a.framePaths.CopyTo(this.framePaths, 0); this.frameGUIDs = new string[a.frameGUIDs.Length]; a.frameGUIDs.CopyTo(this.frameGUIDs, 0); this.spriteFrames = new CSpriteFrame[a.spriteFrames.Length]; for (int i = 0; i < this.spriteFrames.Length; i++) { this.spriteFrames[i] = new CSpriteFrame(a.spriteFrames[i]); } }
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 bool Synch(TextureAnim t) { bool changed = false; if (name != t.name) changed = true; if (loopCycles != t.loopCycles) changed = true; if (loopReverse != t.loopReverse) changed = true; if (framerate != t.framerate) changed = true; name = t.name; loopCycles = t.loopCycles; loopReverse = t.loopReverse; framerate = t.framerate; return changed; }
// Member-wise copy: public void Copy(TextureAnim a) { name = a.name; loopCycles = a.loopCycles; loopReverse = a.loopReverse; framerate = a.framerate; onAnimEnd = a.onAnimEnd; framePaths = new string[a.framePaths.Length]; a.framePaths.CopyTo(framePaths, 0); frameGUIDs = new string[a.frameGUIDs.Length]; a.frameGUIDs.CopyTo(frameGUIDs, 0); spriteFrames = new CSpriteFrame[a.spriteFrames.Length]; for (int i = 0; i < spriteFrames.Length; ++i) { spriteFrames[i] = new CSpriteFrame(a.spriteFrames[i]); } }
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); }
/// <summary> /// Copies all the attributes of another sprite, /// including its edit-time TextureAnimations. /// </summary> /// <param name="s">A reference to the sprite to be copied.</param> public virtual void CopyAll(SpriteRoot s) { AutoSpriteBase sp; base.Copy(s); // Check the type: if (!(s is AutoSpriteBase)) return; sp = (AutoSpriteBase)s; States = new TextureAnim[sp.States.Length]; for (int i = 0; i < States.Length; ++i) { States[i] = new TextureAnim(); States[i].Copy(sp.States[i]); } animations = new UVAnimation[States.Length]; for (int i = 0; i < States.Length; ++i) { animations[i] = new UVAnimation(); animations[i].SetAnim(States[i], i); } doNotTrimImages = sp.doNotTrimImages; }
// Member-wise copy: public void Copy(TextureAnim a) { name = a.name; loopCycles = a.loopCycles; loopReverse = a.loopReverse; framerate = a.framerate; onAnimEnd = a.onAnimEnd; framePaths = new string[a.framePaths.Length]; a.framePaths.CopyTo(framePaths, 0); frameGUIDs = new string[a.frameGUIDs.Length]; a.frameGUIDs.CopyTo(frameGUIDs, 0); spriteFrames = new CSpriteFrame[a.spriteFrames.Length]; for (int i = 0; i < spriteFrames.Length; ++i) spriteFrames[i] = new CSpriteFrame(a.spriteFrames[i]); }
/// <summary> /// Assigns all the various animation info to this animation /// from the specified TextureAnim, replacing any existing /// animation data. /// </summary> /// <param name="anim">Reference to the TextureAnim containing the desired info.</param> /// <param name="idx">The index of this animation.</param> public void SetAnim(TextureAnim anim, int idx) { if (anim == null) return; if (anim.spriteFrames == null) return; frames = new SPRITE_FRAME[anim.spriteFrames.Length]; index = idx; name = anim.name; loopCycles = anim.loopCycles; loopReverse = anim.loopReverse; framerate = anim.framerate; onAnimEnd = anim.onAnimEnd; try { for (int i = 0; i < frames.Length; ++i) { frames[i] = anim.spriteFrames[i].ToStruct(); } } catch (System.Exception err) { Debug.LogError("Exception caught in UVAnimation.SetAnim(). Make sure you have re-built your atlases!\nException: " + err.Message); } CalcLength(); }
void DeleteCurrentAnimation() { TextureAnim[] newList = new TextureAnim[sprite.States.Length - 1]; for (int i = 0, j = 0; i < sprite.States.Length; ++i) { if (i != selectedAnim) { newList[j] = sprite.States[i]; ++j; } else continue; } ((PackedSprite)sprite).textureAnimations = newList; SetupSelection(); EditorUtility.SetDirty(sprite.gameObject); }