/// <summary> /// Clear all textures/etc. destroy the current target objects, and then start from scratch. /// Necessary, if, for example, the RectTransform size has changed. /// Fairly performance-intensive - only call this if strictly necessary. /// </summary> public void HardUpdateDisplay() { var color = this.color; if (Application.isPlaying) { this.color = new Color(0, 0, 0, 0); //imageComponent.sprite = null; } DestroyResources(); Cleanup(); //UpdateDisplay(); FrameTimer.AtEndOfFrame(() => UpdateDisplay(), this); FrameTimer.DelayedCall(0.05f, () => { this.color = color; }, this, true); }
/// <summary> /// Unity's Start() method. Used for initialization. /// </summary> protected override void Start() { base.Start(); var color = this.color; if (Application.isPlaying) { this.color = new Color(0, 0, 0, 0); //imageComponent.sprite = null; } FrameTimer.AtEndOfFrame(() => SetStarted(), this, true); FrameTimer.AtEndOfFrame(() => OnEnable(), this); // Some models (particularly, models with rigs) can cause Unity to crash if they are instantiated this early (for some reason) // as such, we must delay very briefly to avoid this before rendering FrameTimer.DelayedCall(0.01f, () => { Cleanup(); UpdateDisplay(); FrameTimer.DelayedCall(0.05f, () => { this.color = color; }, this, true); }, this, true); }