示例#1
0
        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();
            }
        }
        private void GenerateScrollItem(int index, float position, bool topItem)
        {
            int            itemType       = dataSourceInterface.GetItemType(index);
            ScrollItemInfo scrollItemInfo = GetPooledObj(itemType);

            scrollItemInfo.index = index;
            scrollItemInfo.obj   = dataSourceInterface.GetListItem(index, itemType, scrollItemInfo.obj);

            if (scrollItemInfo.obj == null)
            {
                return;
            }

            scrollItemInfo.obj.SetActive(true);
            scrollItemInfo.obj.transform.SetParent(content, false);

            SetupRectTransform(scrollItemInfo.obj.transform as RectTransform);

            visibleObjects.Add(scrollItemInfo);

            if (!CanvasUpdateRegistry.IsRebuildingLayout())
            {
                Canvas.ForceUpdateCanvases();
            }

            PositionScrollItem(scrollItemInfo, position, topItem);

            UpdateScrollItems();
        }
        protected virtual void ValidateLayoutFeedbacksInChildren()
        {
            var isRebuildingLayout = CanvasUpdateRegistry.IsRebuildingLayout();

            for (int i = 0; i < rectTransform.childCount; i++)
            {
                var rect = rectTransform.GetChild(i) as RectTransform;
                if (rect == null || !rect.gameObject.activeInHierarchy)
                {
                    continue;
                }

                var layoutFeedbackElement = rect.GetComponent <IFastLayoutFeedback>();
                if (layoutFeedbackElement == null)
                {
                    layoutFeedbackElement = rect.gameObject.AddComponent <FastLayoutFeedback>();
                    if (isRebuildingLayout)
                    {
                        layoutFeedbackElement.CalculateLayoutInputHorizontal();
                        layoutFeedbackElement.CalculateLayoutInputVertical();
                    }
                }
                else if (i < m_Children.Count && layoutFeedbackElement != m_Children[i])
                {
                    SetElementDirty(m_Children[i], DrivenAxis.Ignore);
                }
            }
        }
 private void EnsureLayoutHasRebuilt()
 {
     if (!m_HasRebuiltLayout && !CanvasUpdateRegistry.IsRebuildingLayout())
     {
         Canvas.ForceUpdateCanvases();
     }
 }
示例#5
0
        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();
            }
        }
示例#6
0
        //-------------------------------------------------------------------------------------

        /// <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();
            }
        }
示例#7
0
 private void EnsureLayoutHasRebuilt()
 {
     if (this.m_HasRebuiltLayout || CanvasUpdateRegistry.IsRebuildingLayout())
     {
         return;
     }
     Canvas.ForceUpdateCanvases();
 }
示例#8
0
    public void SetDirty()
    {
        if (CanvasUpdateRegistry.IsRebuildingLayout())
        {
            return;
        }

        LayoutRebuilder.MarkLayoutForRebuild(Rect);
    }
        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;
        }
示例#10
0
 private void SetDirty()
 {
     if (IsActive())
     {
         if (!CanvasUpdateRegistry.IsRebuildingLayout())
         {
             LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
         }
     }
 }
    private void SetDirty()
    {
        if (CanvasUpdateRegistry.IsRebuildingLayout())
        {
            // we are already in the process of rebuilding
            // no reason to ask for it again
            return;
        }

        LayoutRebuilder.MarkLayoutForRebuild(Rect);
    }
 // Token: 0x06002123 RID: 8483 RVA: 0x0009B958 File Offset: 0x00099B58
 private void SetDirty()
 {
     if (!base.isActiveAndEnabled)
     {
         return;
     }
     if (!CanvasUpdateRegistry.IsRebuildingLayout())
     {
         LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform);
     }
 }
示例#13
0
 public void MarkVerticesDirty()
 {
     if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout())
     {
         UpdateGeometry();
     }
     else
     {
         SetVerticesDirty();
     }
 }
 /// <summary>
 /// Graphicsの再構築を要求します。再フォーマットは要求しません。
 /// </summary>
 public void MarkAsRebuildRequired()
 {
     // uGUIのText.FontTextureChanged() を参考に。
     if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout())
     {
         this.UpdateGeometry();
     }
     else
     {
         this.SetAllDirty();
     }
 }
示例#15
0
 protected override void UpdateGeometry()
 {
     if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout())
     {
         OnPopulateMeshImmediately(s_ImageVertexHelper);
         s_ImageVertexHelper.FillMesh(ImageMesh);
         canvasRenderer.SetMesh(ImageMesh);
     }
     else
     {
         base.UpdateGeometry();
     }
 }
示例#16
0
 /// <summary>
 /// Sets this layout as dirty.
 /// </summary>
 protected virtual void SetDirty()
 {
     if (gameObject != null && IsActive())
     {
         if (CanvasUpdateRegistry.IsRebuildingLayout())
         {
             LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
         }
         else
         {
             StartCoroutine(DelayedSetDirty(rectTransform));
         }
     }
 }
        protected virtual void CalculateRectTransformDimensions(bool canDirtyInLayoutRebuild = false)
        {
            cachedRectWidth  = rectTransform.sizeDelta.x;
            cachedRectHeight = rectTransform.sizeDelta.y;

            //Prevent change size while calculating feedback
            if (!canDirtyInLayoutRebuild && CanvasUpdateRegistry.IsRebuildingLayout())
            {
                _dirtyAxis = DrivenAxis.None;
            }
            else
            {
                SendFeedback();
            }
        }
    /// <summary>
    /// Creates a new list item to be positioned in the list.
    /// </summary>
    private void GenerateListItem(int index, float position, bool topItem)
    {
        if (itemRendererFactory == null)
        {
            Debug.LogError("Item Renderer Factory is not set!");
            return;
        }

        int          itemType     = onGetItemType(index);
        ListItemInfo listItemInfo = GetPooledObj(itemType);

        // Get the list items object and set up some parameters
        listItemInfo.index = index;
        IListItemView view = listItemInfo.view;

        if (listItemInfo.obj == null)
        {
            listItemInfo.obj = itemRendererFactory(index, content);
            Assert.IsNotNull(listItemInfo.obj);
            view             = listItemInfo.obj.GetComponent <IListItemView>();
            view.OnSelected += OnSelectedItemBroadcast;
        }

        Assert.IsNotNull(view);
        Assert.IsNotNull(dataProvider);
        Assert.IsTrue(index >= 0 && index < dataProvider.Count, "DataProvider index is out of range!");

        view.isSelected   = (index == _isSelectedIndex);
        view.viewData     = dataProvider[index];
        listItemInfo.view = view;


        listItemInfo.obj.SetActive(true);
        listItemInfo.obj.transform.SetParent(content, false);

        SetupRectTransform(listItemInfo.obj.transform as RectTransform);

        visibleObjs.Add(listItemInfo);

        if (!CanvasUpdateRegistry.IsRebuildingLayout())
        {
            Canvas.ForceUpdateCanvases();
        }

        PositionListItem(listItemInfo, position, topItem);

        UpdateListItems();
    }
示例#19
0
        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 void SetDirty()
 {
     if (!IsActive())
     {
         return;
     }
     if (CanvasUpdateRegistry.IsRebuildingLayout())
     {
         StartCoroutine(DelayedSetDirty(rectTransform));
     }
     else
     {
         CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
         LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
     }
 }
        protected void SetDirty(RectTransform rectTransform)
        {
            if (!IsActive())
            {
                return;
            }

            if (!CanvasUpdateRegistry.IsRebuildingLayout())
            {
                LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
            }
            else
            {
                StartCoroutine(DelayedSetDirty(rectTransform));
            }
        }
示例#22
0
 protected override void OnRectTransformDimensionsChange()
 {
     Debug.Log("OnRectTransformDimensionsChange");
     if (gameObject.activeInHierarchy)
     {
         if (CanvasUpdateRegistry.IsRebuildingLayout())
         {
             SetVerticesDirty();
         }
         else
         {
             SetVerticesDirty();
             SetLayoutDirty();
         }
     }
 }
        protected void SetDirty()
        {
            if (!IsActive() || m_awaitingRebuild)
            {
                return;
            }

            if (!CanvasUpdateRegistry.IsRebuildingLayout())
            {
                LayoutRebuilder.MarkLayoutForRebuild(transform as RectTransform);
            }
            else
            {
                m_awaitingRebuild = true;
                StartCoroutine(DelayedSetDirty(transform as RectTransform));
            }
        }
示例#24
0
    public static int IsRebuildingLayout_s(IntPtr l)
    {
        int result;

        try
        {
            bool b = CanvasUpdateRegistry.IsRebuildingLayout();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, b);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
        protected virtual void MarkLayoutForRebuild()
        {
            if (IsDestroyed() || !IsActive())
            {
                return;
            }

            if (!CanvasUpdateRegistry.IsRebuildingLayout())
            {
                CancelInvoke("MarkLayoutForRebuild");
                LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform);
            }
            else if (!IsInvoking("MarkLayoutForRebuild"))
            {
                Invoke("MarkLayoutForRebuild", 0);
            }
        }
        private IEnumerator OnRectTransformDimensionsChange()
        {
            if (this._rt == null || this.ParentCanvas == null || this.ParentCanvas.renderMode == RenderMode.WorldSpace)
            {
                yield break;
            }

            if (CanvasUpdateRegistry.IsRebuildingLayout())
            {
                yield return(null);
            }

            bool oldVisible = this._isVisible;

            this._isVisible = !this.ParentCanvas.pixelPerfect || VisibleComponent.IsRectVisible(this._rt);

            if (!oldVisible && this._isVisible)
            {
                this.BecameVisible();
            }
        }
示例#27
0
        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();
            }
        }
示例#28
0
        protected override void OnRectTransformDimensionsChange()
        {
            if (gameObject.activeInHierarchy)
            {
                // prevent double dirtying...
                if (CanvasUpdateRegistry.IsRebuildingLayout())
                {
                    if (last_size == rectTransform.rect.size)
                    {
                        return;
                    }

                    SetLayoutDirty();
                }
                else
                {
                    if (last_size != rectTransform.rect.size)
                    {
                        SetVerticesDirty();
                    }
                    SetLayoutDirty();
                }
            }
        }
示例#29
0
        // 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();
                }
            }
        }
示例#30
0
            public static IEnumerator UpdateTextures(CelestialBody celestialBody, TextureOptions options)
            {
                // Get time
                DateTime now = DateTime.Now;

                // If the user wants to export normals, we need height too
                if (options.ExportNormal)
                {
                    options.ExportHeight = true;
                }

                // Prepare the PQS
                PQS pqsVersion = celestialBody.pqsController;

                // If the PQS is null, abort
                if (pqsVersion == null)
                {
                    throw new InvalidOperationException();
                }

                // Tell the PQS that we are going to build maps
                pqsVersion.SetupExternalRender();

                // Get the mod building methods from the PQS
                Action <PQS.VertexBuildData> modOnVertexBuildHeight =
                    (Action <PQS.VertexBuildData>)Delegate.CreateDelegate(
                        typeof(Action <PQS.VertexBuildData>),
                        pqsVersion,
                        typeof(PQS).GetMethod("Mod_OnVertexBuildHeight",
                                              BindingFlags.Instance | BindingFlags.NonPublic));
                Action <PQS.VertexBuildData> modOnVertexBuild = (Action <PQS.VertexBuildData>)Delegate.CreateDelegate(
                    typeof(Action <PQS.VertexBuildData>),
                    pqsVersion,
                    typeof(PQS).GetMethod("Mod_OnVertexBuild", BindingFlags.Instance | BindingFlags.NonPublic));

                // Get all mods the PQS is connected to
                PQSMod[] mods = pqsVersion.GetComponentsInChildren <PQSMod>()
                                .Where(m => m.sphere == pqsVersion && m.modEnabled).OrderBy(m => m.order).ToArray();

                // Prevent the PQS from updating
                pqsVersion.enabled = false;

                // Create the Textures
                Texture2D colorMap = new Texture2D(pqsVersion.mapFilesize, pqsVersion.mapFilesize / 2,
                                                   TextureFormat.ARGB32,
                                                   true);
                Texture2D heightMap = new Texture2D(pqsVersion.mapFilesize, pqsVersion.mapFilesize / 2,
                                                    TextureFormat.RGB24,
                                                    true);

                // Arrays
                Color[] colorMapValues  = new Color[pqsVersion.mapFilesize * (pqsVersion.mapFilesize / 2)];
                Color[] heightMapValues = new Color[pqsVersion.mapFilesize * (pqsVersion.mapFilesize / 2)];

                // Create a VertexBuildData
                PQS.VertexBuildData data = new PQS.VertexBuildData();

                // Display
                ScreenMessage message = ScreenMessages.PostScreenMessage("Generating Planet-Maps", Single.MaxValue, ScreenMessageStyle.UPPER_CENTER);

                yield return(null);

                // Loop through the pixels
                for (Int32 y = 0; y < pqsVersion.mapFilesize / 2; y++)
                {
                    for (Int32 x = 0; x < pqsVersion.mapFilesize; x++)
                    {
                        // Update Message
                        Double percent = (Double)(y * pqsVersion.mapFilesize + x) /
                                         (pqsVersion.mapFilesize / 2 * pqsVersion.mapFilesize) * 100;
                        while (CanvasUpdateRegistry.IsRebuildingLayout())
                        {
                            Thread.Sleep(10);
                        }
                        message.textInstance.text.text = "Generating Planet-Maps: " + percent.ToString("0.00") + "%";

                        // Update the VertexBuildData
                        data.directionFromCenter =
                            QuaternionD.AngleAxis(360d / pqsVersion.mapFilesize * x, Vector3d.up) *
                            QuaternionD.AngleAxis(90d - 180d / (pqsVersion.mapFilesize / 2f) * y, Vector3d.right)
                            * Vector3d.forward;
                        data.vertHeight = pqsVersion.radius;

                        // Build from the Mods
                        Double height = Double.MinValue;
                        if (options.ExportHeight)
                        {
                            modOnVertexBuildHeight(data);

                            // Adjust the height
                            height = (data.vertHeight - pqsVersion.radius) * (1d / pqsVersion.mapMaxHeight);
                            if (height < 0)
                            {
                                height = 0;
                            }
                            else if (height > 1)
                            {
                                height = 1;
                            }

                            // Set the Pixels
                            heightMapValues[y * pqsVersion.mapFilesize + x] =
                                new Color((Single)height, (Single)height, (Single)height);
                        }

                        if (options.ExportColor)
                        {
                            modOnVertexBuild(data);

                            // Adjust the Color
                            Color color = data.vertColor;
                            if (!pqsVersion.mapOcean)
                            {
                                color.a = 1f;
                            }
                            else if (height > pqsVersion.mapOceanHeight)
                            {
                                color.a = options.TransparentMaps ? 0f : 1f;
                            }
                            else
                            {
                                color = pqsVersion.mapOceanColor.A(1f);
                            }

                            // Set the Pixels
                            colorMapValues[y * pqsVersion.mapFilesize + x] = color;
                        }
                    }

                    yield return(null);
                }

                // Serialize the maps to disk
                String name = "KittopiaTech/PluginData/" + celestialBody.transform.name + "/";
                String path = KSPUtil.ApplicationRootPath + "/GameData/" + name;

                Directory.CreateDirectory(path);

                // Colormap
                if (options.ExportColor)
                {
                    // Save it
                    colorMap.SetPixels(colorMapValues);
                    yield return(null);

                    if (options.SaveToDisk)
                    {
                        File.WriteAllBytes(path + celestialBody.transform.name + "_Color.png", colorMap.EncodeToPNG());
                        colorMap.name = name + celestialBody.transform.name + "_Color.png";
                        yield return(null);
                    }

                    // Apply it
                    if (options.ApplyToScaled)
                    {
                        colorMap.Apply();
                        celestialBody.scaledBody.GetComponent <MeshRenderer>().material.SetTexture("_MainTex", colorMap);
                    }
                }

                if (options.ExportHeight)
                {
                    heightMap.SetPixels(heightMapValues);
                    yield return(null);

                    if (options.SaveToDisk)
                    {
                        File.WriteAllBytes(path + celestialBody.transform.name + "_Height.png",
                                           heightMap.EncodeToPNG());
                        yield return(null);
                    }

                    if (options.ExportNormal)
                    {
                        // Bump to Normal Map
                        Texture2D normalMap = Utility.BumpToNormalMap(heightMap, pqsVersion.radius, options.NormalStrength);
                        yield return(null);

                        if (options.SaveToDisk)
                        {
                            File.WriteAllBytes(path + celestialBody.transform.name + "_Normal.png",
                                               normalMap.EncodeToPNG());
                            normalMap.name = name + celestialBody.transform.name + "_Normal.png";
                            yield return(null);
                        }

                        // Apply it
                        if (options.ApplyToScaled)
                        {
                            normalMap.Apply();
                            celestialBody.scaledBody.GetComponent <MeshRenderer>().material
                            .SetTexture("_BumpMap", normalMap);
                        }
                    }
                }

                // Close the Renderer
                pqsVersion.enabled = true;
                pqsVersion.CloseExternalRender();

                // Declare that we're done
                ScreenMessages.RemoveMessage(message);
                ScreenMessages.PostScreenMessage("Operation completed in: " + (DateTime.Now - now).TotalMilliseconds + " ms", 2f, ScreenMessageStyle.UPPER_CENTER);
            }