public override void Reset() { UiAnimation.UiTexture uiTexture = (UiAnimation.UiTexture) this.m_texture; Vector2 localPosition = uiTexture.m_localPosition; RectTransform rectTransform = uiTexture.m_image.get_rectTransform(); rectTransform.set_localPosition(localPosition); }
public override void Update(float elapsedTime, float maxTime, bool reverse) { bool flag; float unitProgress = base.GetUnitProgress(elapsedTime, maxTime, reverse, out flag); if (!flag) { return; } float alpha = this.m_fromAlpha + (this.m_toAlpha - this.m_fromAlpha) * unitProgress; UiAnimation.UiTexture uiTexture = (UiAnimation.UiTexture) this.m_texture; uiTexture.m_image.get_canvasRenderer().SetAlpha(alpha); }
public override void Update(float elapsedTime, float maxTime, bool reverse) { bool flag; float unitProgress = base.GetUnitProgress(elapsedTime, maxTime, reverse, out flag); if (!flag) { return; } UiAnimation.UiTexture uiTexture = (UiAnimation.UiTexture) this.m_texture; RectTransform rectTransform = uiTexture.m_image.get_rectTransform(); Vector2 localPosition = uiTexture.m_localPosition; localPosition.x += this.m_offsetX * unitProgress; localPosition.y += this.m_offsetY * unitProgress; rectTransform.set_localPosition(localPosition); }
public override void Update(float elapsedTime, float maxTime, bool reverse) { bool flag; float unitProgress = base.GetUnitProgress(elapsedTime, maxTime, reverse, out flag); if (!flag) { return; } Vector3 localScale; localScale.x = this.m_fromScaleX + (this.m_toScaleX - this.m_fromScaleX) * unitProgress; localScale.y = this.m_fromScaleY + (this.m_toScaleY - this.m_fromScaleY) * unitProgress; localScale.z = 1f; UiAnimation.UiTexture uiTexture = (UiAnimation.UiTexture) this.m_texture; uiTexture.m_image.get_transform().set_localScale(localScale); }
public override void Update(float elapsedTime, float maxTime, bool reverse) { bool flag; float unitProgress = base.GetUnitProgress(elapsedTime, maxTime, reverse, out flag); if (!flag) { return; } UiAnimation.UiTexture uiTexture = (UiAnimation.UiTexture) this.m_texture; Quaternion localRotation = uiTexture.m_image.get_transform().get_localRotation(); Vector3 eulerAngles = localRotation.get_eulerAngles(); eulerAngles.z = this.m_degrees * unitProgress; localRotation.set_eulerAngles(eulerAngles); uiTexture.m_image.get_transform().set_localRotation(localRotation); }
private GameObject CreateAnimObj(string animName, bool createForInit = false) { UiAnimMgr.AnimData animData; this.m_animData.TryGetValue(animName, ref animData); if (animData == null) { return(null); } GameObject gameObject = null; if (!createForInit && animData.m_availableObjects.get_Count() > 0) { gameObject = animData.m_availableObjects.Pop(); } if (gameObject != null) { if (animData.m_activeObjects.Contains(gameObject)) { Debug.Log("Error! new anim object already in active object list."); } else { animData.m_activeObjects.Add(gameObject); } gameObject.SetActive(true); UiAnimation component = gameObject.GetComponent <UiAnimation>(); component.Reset(); component.m_ID = this.GetNextID(); return(gameObject); } gameObject = new GameObject(); if (createForInit) { animData.m_availableObjects.Push(gameObject); } else if (animData.m_activeObjects.Contains(gameObject)) { Debug.Log("Error! new anim object already in active object list."); } else { animData.m_activeObjects.Add(gameObject); } CanvasGroup canvasGroup = gameObject.AddComponent <CanvasGroup>(); canvasGroup.set_blocksRaycasts(false); canvasGroup.set_interactable(false); gameObject.set_name(animName); UiAnimation uiAnimation = gameObject.AddComponent <UiAnimation>(); uiAnimation.m_ID = this.GetNextID(); uiAnimation.Deserialize(animName); RectTransform rectTransform = gameObject.AddComponent <RectTransform>(); rectTransform.SetSizeWithCurrentAnchors(0, uiAnimation.GetFrameWidth()); rectTransform.SetSizeWithCurrentAnchors(1, uiAnimation.GetFrameHeight()); using (Dictionary <string, UiAnimation.UiTexture> .ValueCollection.Enumerator enumerator = uiAnimation.m_textures.get_Values().GetEnumerator()) { while (enumerator.MoveNext()) { UiAnimation.UiTexture current = enumerator.get_Current(); GameObject gameObject2 = new GameObject(); gameObject2.set_name(current.m_parentKey + "_Texture"); gameObject2.get_transform().SetParent(gameObject.get_transform(), false); current.m_image = gameObject2.AddComponent <Image>(); current.m_image.set_sprite(current.m_sprite); current.m_image.get_canvasRenderer().SetAlpha(current.m_alpha); if (current.m_alphaMode == "ADD") { current.m_image.set_material(new Material(UiAnimMgr.instance.m_additiveMaterial)); } else { current.m_image.set_material(new Material(UiAnimMgr.instance.m_blendMaterial)); } current.m_image.get_material().set_mainTexture(current.m_sprite.get_texture()); RectTransform component2 = gameObject2.GetComponent <RectTransform>(); int num; if (current.m_anchor != null && current.m_anchor.relativePoint != null) { string text = current.m_anchor.relativePoint; if (text != null) { if (UiAnimMgr.< > f__switch$map9 == null) { Dictionary <string, int> dictionary = new Dictionary <string, int>(9); dictionary.Add("TOP", 0); dictionary.Add("BOTTOM", 1); dictionary.Add("LEFT", 2); dictionary.Add("RIGHT", 3); dictionary.Add("CENTER", 4); dictionary.Add("TOPLEFT", 5); dictionary.Add("TOPRIGHT", 6); dictionary.Add("BOTTOMLEFT", 7); dictionary.Add("BOTTOMRIGHT", 8); UiAnimMgr.< > f__switch$map9 = dictionary; } if (UiAnimMgr.< > f__switch$map9.TryGetValue(text, ref num)) { switch (num) { case 0: component2.set_anchorMin(new Vector2(0.5f, 1f)); component2.set_anchorMax(component2.get_anchorMin()); break; case 1: component2.set_anchorMin(new Vector2(0.5f, 0f)); component2.set_anchorMax(component2.get_anchorMin()); break; case 2: component2.set_anchorMin(new Vector2(0f, 0.5f)); component2.set_anchorMax(component2.get_anchorMin()); break; case 3: component2.set_anchorMin(new Vector2(1f, 0.5f)); component2.set_anchorMax(component2.get_anchorMin()); break; case 4: component2.set_anchorMin(new Vector2(0.5f, 0.5f)); component2.set_anchorMax(component2.get_anchorMin()); break; case 5: component2.set_anchorMin(new Vector2(0f, 1f)); component2.set_anchorMax(component2.get_anchorMin()); break; case 6: component2.set_anchorMin(new Vector2(1f, 1f)); component2.set_anchorMax(component2.get_anchorMin()); break; case 7: component2.set_anchorMin(new Vector2(0f, 0f)); component2.set_anchorMax(component2.get_anchorMin()); break; case 8: component2.set_anchorMin(new Vector2(1f, 0f)); component2.set_anchorMax(component2.get_anchorMin()); break; } } } } Vector2 anchoredPosition = default(Vector2); if (current.m_anchor != null && current.m_anchor.point != null) { string text = current.m_anchor.point; if (text != null) { if (UiAnimMgr.< > f__switch$mapA == null) { Dictionary <string, int> dictionary = new Dictionary <string, int>(9); dictionary.Add("TOP", 0); dictionary.Add("BOTTOM", 1); dictionary.Add("LEFT", 2); dictionary.Add("RIGHT", 3); dictionary.Add("CENTER", 4); dictionary.Add("TOPLEFT", 5); dictionary.Add("TOPRIGHT", 6); dictionary.Add("BOTTOMLEFT", 7); dictionary.Add("BOTTOMRIGHT", 8); UiAnimMgr.< > f__switch$mapA = dictionary; } if (UiAnimMgr.< > f__switch$mapA.TryGetValue(text, ref num)) { switch (num) { case 0: anchoredPosition.Set(0f, -0.5f * current.m_image.get_sprite().get_rect().get_height()); break; case 1: anchoredPosition.Set(0f, 0.5f * current.m_image.get_sprite().get_rect().get_height()); break; case 2: anchoredPosition.Set(0.5f * current.m_image.get_sprite().get_rect().get_width(), 0f); break; case 3: anchoredPosition.Set(-0.5f * current.m_image.get_sprite().get_rect().get_width(), 0f); break; case 5: anchoredPosition.Set(0.5f * current.m_image.get_sprite().get_rect().get_width(), -0.5f * current.m_image.get_sprite().get_rect().get_height()); break; case 6: anchoredPosition.Set(-0.5f * current.m_image.get_sprite().get_rect().get_width(), -0.5f * current.m_image.get_sprite().get_rect().get_height()); break; case 7: anchoredPosition.Set(0.5f * current.m_image.get_sprite().get_rect().get_width(), 0.5f * current.m_image.get_sprite().get_rect().get_height()); break; case 8: anchoredPosition.Set(-0.5f * current.m_image.get_sprite().get_rect().get_width(), 0.5f * current.m_image.get_sprite().get_rect().get_height()); break; } } } } component2.set_anchoredPosition(anchoredPosition); component2.SetSizeWithCurrentAnchors(0, current.m_image.get_sprite().get_rect().get_width()); component2.SetSizeWithCurrentAnchors(1, current.m_image.get_sprite().get_rect().get_height()); } } using (Dictionary <string, UiAnimation.UiTexture> .ValueCollection.Enumerator enumerator2 = uiAnimation.m_textures.get_Values().GetEnumerator()) { while (enumerator2.MoveNext()) { UiAnimation.UiTexture current2 = enumerator2.get_Current(); RectTransform rectTransform2 = current2.m_image.get_rectTransform(); current2.m_localPosition = rectTransform2.get_localPosition(); } } return(gameObject); }
private void Update() { if (this.m_state != UiAnimation.State.Playing && this.m_state != UiAnimation.State.Stopping) { return; } bool flag = true; using (List <UiAnimation.UiAnimGroup> .Enumerator enumerator = this.m_groups.GetEnumerator()) { while (enumerator.MoveNext()) { UiAnimation.UiAnimGroup current = enumerator.get_Current(); if (!current.Update(this.m_state == UiAnimation.State.Stopping)) { flag = false; } } } bool flag2 = false; if (this.m_state == UiAnimation.State.Playing && this.m_fadeTime > 0f) { float num = (Time.get_timeSinceLevelLoad() - this.m_fadeStart) / this.m_fadeTime; if (num >= 1f) { this.m_fadeTime = 0f; num = 1f; } flag2 = true; this.m_fadeAlphaScalar = num; } if (this.m_state == UiAnimation.State.Stopping) { flag = false; float num2 = (Time.get_timeSinceLevelLoad() - this.m_fadeStart) / this.m_fadeTime; if (num2 >= 1f) { num2 = 1f; flag = true; } num2 = 1f - num2; this.m_fadeAlphaScalar = num2; flag2 = true; } if (flag2) { using (Dictionary <string, UiAnimation.UiTexture> .ValueCollection.Enumerator enumerator2 = this.m_textures.get_Values().GetEnumerator()) { while (enumerator2.MoveNext()) { UiAnimation.UiTexture current2 = enumerator2.get_Current(); current2.m_image.get_canvasRenderer().SetAlpha(current2.m_alpha * this.m_fadeAlphaScalar); } } } if (flag) { this.m_state = UiAnimation.State.Stopped; this.m_fadeTime = 0f; UiAnimMgr.instance.AnimComplete(this); } }
public void Deserialize(string animName) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(UiAnimation.UiSourceAnimation)); xmlSerializer.add_UnknownNode(new XmlNodeEventHandler(this.serializer_UnknownNode)); xmlSerializer.add_UnknownAttribute(new XmlAttributeEventHandler(this.serializer_UnknownAttribute)); TextAsset sourceData = UiAnimMgr.instance.GetSourceData(animName); if (sourceData == null) { Debug.Log("Could not find asset " + animName); return; } MemoryStream memoryStream = new MemoryStream(sourceData.get_bytes()); UiAnimation.UiSourceAnimation uiSourceAnimation = xmlSerializer.Deserialize(memoryStream) as UiAnimation.UiSourceAnimation; memoryStream.Close(); if (uiSourceAnimation == null) { Debug.Log("No ui animation."); return; } this.m_frame = uiSourceAnimation.frame; using (List <UiAnimation.UiSourceAnimGroup> .Enumerator enumerator = uiSourceAnimation.frame.animation.groups.GetEnumerator()) { while (enumerator.MoveNext()) { UiAnimation.UiSourceAnimGroup current = enumerator.get_Current(); UiAnimation.UiAnimGroup uiAnimGroup = new UiAnimation.UiAnimGroup(); uiAnimGroup.m_parentKey = current.parentKey; uiAnimGroup.m_bounceBack = false; if (current.looping == null) { uiAnimGroup.m_looping = false; uiAnimGroup.m_bounce = false; } else if (current.looping == "REPEAT") { uiAnimGroup.m_looping = true; uiAnimGroup.m_bounce = false; } else if (current.looping == "BOUNCE") { uiAnimGroup.m_looping = true; uiAnimGroup.m_bounce = true; } using (List <UiAnimation.UiScale> .Enumerator enumerator2 = current.m_scales.GetEnumerator()) { while (enumerator2.MoveNext()) { UiAnimation.UiScale current2 = enumerator2.get_Current(); if (current2.m_childKey != null) { current2.SetSmoothing(); uiAnimGroup.m_elements.Add(current2); } } } using (List <UiAnimation.UiAlpha> .Enumerator enumerator3 = current.m_alphas.GetEnumerator()) { while (enumerator3.MoveNext()) { UiAnimation.UiAlpha current3 = enumerator3.get_Current(); if (current3.m_childKey != null) { current3.SetSmoothing(); uiAnimGroup.m_elements.Add(current3); } } } using (List <UiAnimation.UiRotation> .Enumerator enumerator4 = current.m_rotations.GetEnumerator()) { while (enumerator4.MoveNext()) { UiAnimation.UiRotation current4 = enumerator4.get_Current(); if (current4.m_childKey != null) { current4.SetSmoothing(); uiAnimGroup.m_elements.Add(current4); } } } using (List <UiAnimation.UiTranslation> .Enumerator enumerator5 = current.m_translations.GetEnumerator()) { while (enumerator5.MoveNext()) { UiAnimation.UiTranslation current5 = enumerator5.get_Current(); if (current5.m_childKey != null) { current5.SetSmoothing(); uiAnimGroup.m_elements.Add(current5); } } } this.m_groups.Add(uiAnimGroup); } } using (List <UiAnimation.UiLayer> .Enumerator enumerator6 = uiSourceAnimation.frame.layers.GetEnumerator()) { while (enumerator6.MoveNext()) { UiAnimation.UiLayer current6 = enumerator6.get_Current(); using (List <UiAnimation.UiSourceTexture> .Enumerator enumerator7 = current6.textures.GetEnumerator()) { UiAnimation.UiSourceTexture texture; while (enumerator7.MoveNext()) { texture = enumerator7.get_Current(); if (texture.m_parentKey != null) { UiAnimation.UiTexture uiTexture; this.m_textures.TryGetValue(texture.m_parentKey, ref uiTexture); if (uiTexture != null) { Debug.Log("Found duplicate texture " + texture.m_parentKey); } else { int textureAtlasMemberID = 0; StaticDB.uiTextureAtlasMemberDB.EnumRecords(delegate(UiTextureAtlasMemberRec memberRec) { if (memberRec.CommittedName != null && texture.m_atlas != null && memberRec.CommittedName.ToLower() == texture.m_atlas.ToLower()) { textureAtlasMemberID = memberRec.ID; return(false); } return(true); }); if (textureAtlasMemberID > 0) { Sprite sprite = TextureAtlas.GetSprite(textureAtlasMemberID); if (sprite != null) { UiAnimation.UiTexture uiTexture2 = new UiAnimation.UiTexture(); uiTexture2.m_alpha = texture.m_alpha; uiTexture2.m_alphaMode = texture.m_alphaMode; uiTexture2.m_anchor = ((texture.m_anchors.get_Count() <= 0) ? null : texture.m_anchors.ToArray()[0]); uiTexture2.m_atlas = texture.m_atlas; uiTexture2.m_hidden = texture.m_hidden; uiTexture2.m_parentKey = texture.m_parentKey; uiTexture2.m_sprite = sprite; this.m_textures.Add(texture.m_parentKey, uiTexture2); } else { Debug.Log(string.Concat(new object[] { "Could not find sprite for textureAtlasMemberID ", textureAtlasMemberID, " in Ui Animation ", animName })); } } } } } } } } List <UiAnimation.UiAnimElement> list = new List <UiAnimation.UiAnimElement>(); using (List <UiAnimation.UiAnimGroup> .Enumerator enumerator8 = this.m_groups.GetEnumerator()) { while (enumerator8.MoveNext()) { UiAnimation.UiAnimGroup current7 = enumerator8.get_Current(); current7.m_maxTime = 0f; using (List <UiAnimation.UiAnimElement> .Enumerator enumerator9 = current7.m_elements.GetEnumerator()) { while (enumerator9.MoveNext()) { UiAnimation.UiAnimElement current8 = enumerator9.get_Current(); UiAnimation.UiTexture uiTexture3 = null; this.m_textures.TryGetValue(current8.m_childKey, ref uiTexture3); if (uiTexture3 != null) { current8.m_texture = uiTexture3; float totalTime = current8.GetTotalTime(); if (totalTime > current7.m_maxTime) { current7.m_maxTime = totalTime; } } else { list.Add(current8); Debug.Log("Removing element with childKey " + current8.m_childKey + ", no associated texture was found."); } } } using (List <UiAnimation.UiAnimElement> .Enumerator enumerator10 = list.GetEnumerator()) { while (enumerator10.MoveNext()) { UiAnimation.UiAnimElement current9 = enumerator10.get_Current(); current7.m_elements.Remove(current9); } } } } }