/// <summary> /// /// </summary> public override void SetMaterialDirty() { if (this == null || !this.IsActive()) { return; } if (CanvasUpdateRegistry.IsRebuildingGraphics()) { if (m_DelayedMaterialRebuild == null) { m_DelayedMaterialRebuild = StartCoroutine(DelayedMaterialRebuild()); } return; } m_isMaterialDirty = true; CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild((ICanvasElement)this); if (m_OnDirtyMaterialCallback != null) { m_OnDirtyMaterialCallback(); } }
public void FontTextureChangedOther() { // Only invoke if we are not destroyed. if (!this) { return; } if (m_DisableFontTextureRebuiltCallback) { return; } if (!IsActive()) { return; } // this is a bit hacky, but it is currently the // cleanest solution.... // if we detect the font texture has changed and are in a rebuild loop // we just regenerate the verts for the new UV's if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { UpdateGeometry(); } else { SetAllDirty(); } }
void Update() { if (SpritesData == null) { return; } if (!SpritesData.IsAnim) { return; } m_SpriteDeltaTime += Time.deltaTime; if (m_SpriteDeltaTime >= SpritesData.AnimSpeed) { m_SpriteDeltaTime = 0.0f; ++m_SpriteCurrentIndex; if (m_SpriteCurrentIndex >= SpritesData.Sprites.Length) { m_SpriteCurrentIndex = 0; } if (!CanvasUpdateRegistry.IsRebuildingGraphics()) { m_Icon.sprite = SpritesData.Sprites[m_SpriteCurrentIndex]; } } }
//------------------------------------------------------------------------------------- /// <summary> /// フォントのテクスチャに更新があった /// </summary> public void FontTextureChanged() { if (this == null) { // 自身は既に破棄されている UntrackText(this); return; } if (m_DisableFontTextureRebuiltCallback == true) { // テクスチャの更新によるメッシュの更新は禁止されている return; } // 頂点情報を更新する cachedTextGenerator.Invalidate(); if (IsActive() == false) { // 自身は非アクティブ状態である return; } if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { // メッシュを更新する UpdateGeometry(); } else { SetAllDirty(); } }
public void FontTextureChanged() { // Only invoke if we are not destroyed. if (!this) { FontUpdateTrackerEx.UntrackText(this); return; } cachedTextGenerator.Invalidate(); if (!IsActive()) { return; } // this is a bit hacky, but it is currently the // cleanest solution.... // if we detect the font texture has changed and are in a rebuild loop // we just regenerate the verts for the new UV's if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { UpdateGeometry(); } else { SetAllDirty(); } }
public void RegistoryElements() { if (CanvasUpdateRegistry.IsRebuildingGraphics()) { } //CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(); }
private void UpdateItems() { if (m_ChildArray == null || m_PerformingUpdateItems) { return; } m_PerformingUpdateItems = true; bool isDirty = false; Rect clipRect = GetViewRect(); if (clipRect != m_ViewportRect || m_IsLayoutDirty) { m_ViewportRect = clipRect; List <int> visibleIndexes = ListPool <int> .Get(); if (m_PreRectChildrenCount > m_RectChildren.Count) { for (int i = m_RectChildren.Count; i < m_PreRectChildrenCount; i++) { dataContent.Release(i); } m_PreRectChildrenCount = m_RectChildren.Count; } for (int i = m_RectChildren.Offset; i < m_RectChildren.Count; i++) { if (m_ViewportRect.Overlaps(m_RectChildren.Array[i].rect)) { visibleIndexes.Add(i); } else { dataContent.Release(i); } } foreach (var index in visibleIndexes) { ChildRect child = m_RectChildren.Array[index]; Rect rect = new Rect(child.rect.min - rectTransform.rect.min, child.rect.size); var childRect = dataContent.Show(index, rect, m_IsLayoutDirty); if (!childRect) { continue; } SetChildAlongAxis(childRect, 0, rect.xMin, rect.width, child.properties); SetChildAlongAxis(childRect, 1, rect.yMin, rect.height, child.properties); isDirty = true; } ListPool <int> .Release(visibleIndexes); m_IsLayoutDirty = false; } if (isDirty && !CanvasUpdateRegistry.IsRebuildingGraphics() && !CanvasUpdateRegistry.IsRebuildingLayout()) { Canvas.ForceUpdateCanvases(); } m_PerformingUpdateItems = false; }
public void MarkVerticesDirty() { if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { UpdateGeometry(); } else { SetVerticesDirty(); } }
public override void SetVerticesDirty() { //Debug.Log("SetVerticesDirty() on Object ID: " + this.GetInstanceID()); if (m_verticesAlreadyDirty || this == null || !this.IsActive() || CanvasUpdateRegistry.IsRebuildingGraphics()) { return; } m_verticesAlreadyDirty = true; CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild((ICanvasElement)this); }
/// <summary> /// Graphicsの再構築を要求します。再フォーマットは要求しません。 /// </summary> public void MarkAsRebuildRequired() { // uGUIのText.FontTextureChanged() を参考に。 if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { this.UpdateGeometry(); } else { this.SetAllDirty(); } }
protected override void UpdateGeometry() { if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { OnPopulateMeshImmediately(s_ImageVertexHelper); s_ImageVertexHelper.FillMesh(ImageMesh); canvasRenderer.SetMesh(ImageMesh); } else { base.UpdateGeometry(); } }
/// <summary> /// /// </summary> public override void SetMaterialDirty() { //Debug.Log("SetMaterialDirty()"); if (this == null || !this.IsActive() || CanvasUpdateRegistry.IsRebuildingGraphics()) { return; } m_isMaterialDirty = true; CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild((ICanvasElement)this); //UpdateMaterial(); }
public override void SetVerticesDirty() { if (m_verticesAlreadyDirty || this == null || !this.IsActive() || CanvasUpdateRegistry.IsRebuildingGraphics()) { return; } m_verticesAlreadyDirty = true; CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild((ICanvasElement)this); if (m_OnDirtyVertsCallback != null) { m_OnDirtyVertsCallback(); } }
private void TextureRebuildCallback(Font targetFont) { Debug.LogWarningFormat("call texture rebulid callback {0}", font.name); if (font == targetFont) { if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { UpdateGeometry(); } else { SetAllDirty(); } } }
public static int IsRebuildingGraphics_s(IntPtr l) { int result; try { bool b = CanvasUpdateRegistry.IsRebuildingGraphics(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, b); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public override void SetVerticesDirty() { if (this == null || !this.IsActive()) { return; } if (CanvasUpdateRegistry.IsRebuildingGraphics()) { return; } CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this); if (m_OnDirtyVertsCallback != null) { m_OnDirtyVertsCallback(); } }
void Update() { if (m_SpriteBeginIndex < m_SpriteEndIndex && m_Icon != null) { m_SpriteDeltaTime += Time.deltaTime; if (m_SpriteDeltaTime >= m_SpriteDuration) { m_SpriteDeltaTime -= m_SpriteDuration; ++m_SpriteCurrentIndex; if (m_SpriteCurrentIndex < m_SpriteBeginIndex || m_SpriteCurrentIndex > m_SpriteEndIndex) { m_SpriteCurrentIndex = m_SpriteBeginIndex; } if (!CanvasUpdateRegistry.IsRebuildingGraphics()) { ShowSpriteIndex(m_SpriteCurrentIndex); } } } }
void OnTextureRebuild(Font font) { if (this == null) { return; } if (!this.IsActive()) { return; } //フォント作成 TextGenerator.OnTextureRebuild(font); if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { //キャンバスのリビルド中はこっち base.UpdateGeometry(); } else { //通常はこっち this.SetVerticesDirty(); } }
// A debug entry is received private void ReceivedLog(string logString, string stackTrace, LogType logType) { if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { // Trying to update the UI while the canvas is being rebuilt will throw warnings in the Unity console queuedLogs.Add(new QueuedDebugLogEntry(logString, stackTrace, logType)); return; } DebugLogEntry logEntry = new DebugLogEntry(logString, stackTrace, null); // Check if this entry is a duplicate (i.e. has been received before) int logEntryIndex; bool isEntryInCollapsedEntryList = collapsedLogEntriesMap.TryGetValue(logEntry, out logEntryIndex); if (!isEntryInCollapsedEntryList) { // It is not a duplicate, // add it to the list of unique debug entries logEntry.logTypeSpriteRepresentation = logSpriteRepresentations[logType]; logEntryIndex = collapsedLogEntries.Count; collapsedLogEntries.Add(logEntry); collapsedLogEntriesMap[logEntry] = logEntryIndex; } else { // It is a duplicate, // increment the original debug item's collapsed count logEntry = collapsedLogEntries[logEntryIndex]; logEntry.count++; } // Add the index of the unique debug entry to the list // that stores the order the debug entries are received uncollapsedLogEntriesIndices.Add(logEntryIndex); // If this debug entry matches the current filters, // add it to the list of debug entries to show Sprite logTypeSpriteRepresentation = logEntry.logTypeSpriteRepresentation; if (isCollapseOn && isEntryInCollapsedEntryList) { if (isLogWindowVisible) { recycledListView.OnCollapsedLogEntryAtIndexUpdated(logEntryIndex); } } else if (logFilter == DebugLogFilter.All || (logTypeSpriteRepresentation == infoLog && ((logFilter & DebugLogFilter.Info) == DebugLogFilter.Info)) || (logTypeSpriteRepresentation == warningLog && ((logFilter & DebugLogFilter.Warning) == DebugLogFilter.Warning)) || (logTypeSpriteRepresentation == errorLog && ((logFilter & DebugLogFilter.Error) == DebugLogFilter.Error))) { indicesOfListEntriesToShow.Add(logEntryIndex); if (isLogWindowVisible) { recycledListView.OnLogEntriesUpdated(false); } } if (logType == LogType.Log) { infoEntryCount++; infoEntryCountText.text = infoEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewInfoLogArrived(); } } else if (logType == LogType.Warning) { warningEntryCount++; warningEntryCountText.text = warningEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewWarningLogArrived(); } } else { errorEntryCount++; errorEntryCountText.text = errorEntryCount.ToString(); // If debug popup is visible, notify it of the new debug entry if (!isLogWindowVisible) { popupManager.NewErrorLogArrived(); } } }
private void ReceivedLog(string logString, string stackTrace, LogType type) { if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout()) { m_QueueLogs.Enqueue(new QueuedLogEntry(logString, stackTrace, type)); return; } LogEntry logEntry = new LogEntry(logString, stackTrace, null); bool isEntryInCollapsedEntryList = m_CollapsedLogEntriesLookup.TryGetValue(logEntry, out int logEntryIdx); // already has entry in list if (isEntryInCollapsedEntryList) { logEntry = m_CollapsedLogEntries[logEntryIdx]; logEntry.count++; } // new one, store to map else { logEntry.typeSprite = m_LogSpriteLookup[type]; logEntryIdx = m_CollapsedLogEntries.Count; m_CollapsedLogEntries.Add(logEntry); m_CollapsedLogEntriesLookup[logEntry] = logEntryIdx; } m_UncollapsedLogEntryIndices.Add(logEntryIdx); if (m_IsCollapsed && isEntryInCollapsedEntryList) { if (m_IsLogWindowVisible) { m_LogWindow.UpdateCollapsedLogEntryAtIdx(logEntryIdx); } } else if (m_IsInfoEnabled || m_IsWarningEnabled || m_IsErrorEnabled) { m_LogEntryIndicesToShow.Add(logEntryIdx); if (m_IsLogWindowVisible) { m_LogWindow.UpdateLogEntries(false); } } if (type == LogType.Warning) { ++m_WarningCount; if (m_IsLogWindowVisible) { m_LogWindow.UpdateWarningCountText(m_WarningCount); } //else //{ // //TODO update mini window count //} } else if (type == LogType.Log) { ++m_InfoCount; if (m_IsLogWindowVisible) { m_LogWindow.UpdateInfoCountText(m_InfoCount); } //else //{ // //TODO update mini window //} } else { ++m_ErrorCount; if (m_IsLogWindowVisible) { m_LogWindow.UpdateErrorCountText(m_ErrorCount); } //else //{ // //TODO update mini window //} } m_LogWindow.SnapToBottom(); }