Example #1
0
        public void OnLayerHeader(Layout layout, int num)
        {
            GrassType block = array[num];

            layout.margin += 5; layout.rightMargin += 5;
            layout.Par(32, padding: 0);

            //checking icon
            if (block.icon == null)
            {
                if (textureArrays)
                {
                    if (mainTexArray != null)
                    {
                        block.icon = new Texture2D(64, 64);
                        mainTexArray.FillTexture(block.icon, num);
                                                        #if UNITY_EDITOR
                        if (UnityEditor.PlayerSettings.colorSpace == ColorSpace.Linear && block.icon != null)
                        {
                            block.icon.ApplyGamma();
                        }
                                                        #endif
                    }
                }
                else
                {
                    block.icon = block.mainTex;
                }
            }

            //icon
            int  iconWidth = (int)layout.cursor.height;
            Rect iconRect  = layout.Inset(iconWidth);
            iconRect = iconRect.Extend(-3);
            layout.Icon(block.icon, iconRect);
            layout.Element(num == selected? "DPLayout_LayerIconActive" : "DPLayout_LayerIconInactive", iconRect, new RectOffset(6, 6, 6, 6), null);

            //label
            Rect labelRect = layout.Inset(layout.field.width - iconWidth - 18 - layout.margin - layout.rightMargin);
            labelRect.y += (labelRect.height - 18) / 2f; labelRect.height = 18;
            block.name   = layout.EditableLabel(block.name, labelRect);

            //drawing foldout where the cursor left

            layout.margin -= 5; layout.rightMargin -= 5;
        }
        public static void CopyTextures(Texture2DArray srcArr, int srcIndex, Texture2DArray dstArr, int dstIndex, int length)
        /// Bulk textures copy from index to index
        {
            //format and size match
            if (srcArr.format == dstArr.format && srcArr.width == dstArr.width && srcArr.height == dstArr.height)
            {
                for (int i = 0; i < length; i++)
                {
                    Graphics.CopyTexture(srcArr, srcIndex + i, dstArr, dstIndex + i);
                }
                dstArr.Apply(updateMipmaps: false);
                return;
            }

            Texture2D tmpTex = new Texture2D(dstArr.width, dstArr.height, dstArr.format, true, linear: srcArr.IsLinear());

            for (int i = 0; i < length; i++)
            {
                srcArr.FillTexture(tmpTex, srcIndex + i);
                Graphics.CopyTexture(tmpTex, 0, dstArr, dstIndex + i);
            }

            dstArr.Apply(updateMipmaps: false);
        }