protected virtual void UpdateVisible() { this.canvasRenderer.cull = !m_Visible; if (inLineImages != null) { int count = inLineImages.Count; for (int i = 0; i < count; i++) { InLineImage item = inLineImages[i]; if (item.image != null) { bool cull = !m_Visible || item.cull; if (cull != item.image.canvasRenderer.cull) { item.image.canvasRenderer.cull = cull; if (!cull) { //不加这个重建在隐藏状态时有变化不会更新 CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(item.image); } } } } } }
public void ClearUnUsedInlineImage() { if (inLineImages != null) { int needCount = inLineCharindex.Count; int count = inLineImages.Count; for (int i = count - 1; i > 0; i--) { InLineImage item = inLineImages[i]; if (item.image != null && i >= needCount) { if (Application.isPlaying) { GameObject.Destroy(item.image.gameObject); } else { GameObject.DestroyImmediate(item.image.gameObject); } item.image = null; } if (item.image == null) { inLineImages.RemoveAt(i); } } } SetVerticesDirty(); m_FilterText = FilterRichText(m_Text); }
private void SetInlineImageCull(int index, bool cull) { InLineImage item = inLineImages[index]; if (item.image == null) { return; } item.cull = cull; if (cull != item.image.canvasRenderer.cull) { item.image.canvasRenderer.cull = cull; if (!cull) { item.image.Rebuild(CanvasUpdate.PreRender); } } }