private void setHidePosition() { UIRectTransform.SetPosY((RectTransform)this.transform, float.MinValue); }
public override void refresh() { if (dirty) { dirty = false; if (this.data != null) { State state = this.data.state.v; if (state != null) { switch (state.getType()) { case State.Type.Show: { Show show = state as Show; // time if (show.time.v <= show.duration.v) { if (Time.time == LastTime) { // Debug.LogError("the same last time: " + LastTime); dirty = true; } else { show.time.v += Time.fixedDeltaTime; } } else { // chuyen sang normal Normal normal = new Normal(); { normal.uid = this.data.state.makeId(); } this.data.state.v = normal; } // UI { RectTransform rectTransform = (RectTransform)this.transform; if (rectTransform != null) { if (rectTransform.rect.height > 0) { if (show.duration.v > 0) { UIRectTransform.SetPosY(rectTransform, Mathf.Clamp( ((show.duration.v - show.time.v) / show.duration.v) * (-rectTransform.rect.height), -rectTransform.rect.height, 0)); } else { Logger.LogError("show duration < 0: " + show.duration.v); } } else { Logger.LogError("rectTransform rect height 0"); } } else { Logger.LogError("rectTransform null"); } } } break; case State.Type.Normal: { UIRectTransform.SetPosY((RectTransform)this.transform, 0); } break; case State.Type.Hide: { Hide hide = state as Hide; if (hide.time.v <= hide.duration.v) { if (Time.time == LastTime) { // Debug.LogError("the same last time: " + LastTime); dirty = true; } else { hide.time.v += Time.fixedDeltaTime; } } else { // chuyen sang normal Normal normal = new Normal(); { normal.uid = this.data.state.makeId(); } this.data.state.v = normal; // event if (this.data.onHide.v != null) { this.data.onHide.v(); } else { Logger.LogError("onHide null"); } } // UI { RectTransform rectTransform = (RectTransform)this.transform; if (rectTransform != null) { if (rectTransform.rect.height > 0) { if (hide.duration.v > 0) { UIRectTransform.SetPosY(rectTransform, Mathf.Clamp( (hide.time.v / hide.duration.v) * (-rectTransform.rect.height), -rectTransform.rect.height, 0)); } else { Logger.LogError("show duration < 0: " + hide.duration.v); } } else { Logger.LogError("rectTransform rect height 0"); } } else { Logger.LogError("rectTransform null"); } } } break; default: Logger.LogError("unknown type: " + state.getType()); break; } LastTime = Time.time; } else { Logger.LogError("state null"); Normal normal = new Normal(); { normal.uid = this.data.state.makeId(); } this.data.state.v = normal; } } else { // Debug.LogError("data null"); } } }