Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        public void OnLayerGUI(Layout layout, int num)
        {
            layout.margin += 5; layout.rightMargin += 5;

            GrassType block = array[num];

            layout.Par();
            layout.Label("Mesh", rect: layout.Inset(0.6f));
            if (layout.Button("Load", rect: layout.Inset(0.4f)))
            {
                Mesh      mesh = null;
                Transform tfm  = layout.LoadAsset <Transform>("Load Grass Mesh");
                if (tfm != null)
                {
                    MeshFilter filter = tfm.GetComponent <MeshFilter>();
                    if (filter != null)
                    {
                        mesh = filter.sharedMesh;
                        if (mesh != null)
                        {
                            block.meshes = new MeshWrapper[4];
                            for (int i = 0; i < 4; i++)
                            {
                                block.meshes[i] = new MeshWrapper();
                                block.meshes[i].ReadMesh(mesh);
                                block.meshes[i].RotateMirror(i * 90, false);
                            }
                        }
                    }
                }
                else if (mesh == null)
                {
                    block.meshes = new MeshWrapper[0];
                }
            }
            layout.Par(5);

            if (!textureArrays && !atlas)
            {
                block.mainTex       = layout.Field(block.mainTex, "Albedo/Alpha");
                block.bumpMap       = layout.Field(block.bumpMap, "Normal");
                block.specSmoothMap = layout.Field(block.specSmoothMap, "Spec/Gloss");
                block.sssVanishMap  = layout.Field(block.sssVanishMap, "SSS");
            }


            layout.fieldSize = 0.3f;
            layout.Par(5);
            layout.Toggle(ref block.onlyTopLevel, "Only Top Level");
            layout.Toggle(ref block.normalsFromTerrain, "Take Terrain Normals");
            layout.Field(ref block.uniformSizeRandom, "Size Random (Uniform)");
            layout.Field(ref block.heightRandom, "Height Random");

            layout.fieldSize = 0.6f;
            Vector2 uvOffset = new Vector2(block.uvRect.x, block.uvRect.y);
            Vector2 uvSize   = new Vector2(block.uvRect.z, block.uvRect.w);

            layout.Label("UV:");
            layout.Field(ref uvOffset, "Offset");
            layout.Field(ref uvSize, "Size");
            block.uvRect = new Vector4(uvOffset.x, uvOffset.y, uvSize.x, uvSize.y);

            layout.Par(5);
            layout.Field(ref block.colorTint, "Color Tint");

            layout.Par();
            layout.Label("Specular", rect: layout.Inset(1 - layout.fieldSize));
            layout.Field(ref block.specularV, "V", rect: layout.Inset(layout.fieldSize / 2), fieldSize: 0.81f);
            layout.Field(ref block.specularM, "M", rect: layout.Inset(layout.fieldSize / 2), fieldSize: 0.81f);

            layout.Par();
            layout.Label("Gloss", rect: layout.Inset(1 - layout.fieldSize));
            layout.Field(ref block.glossinessV, "V", rect: layout.Inset(layout.fieldSize / 2), fieldSize: 0.81f);
            layout.Field(ref block.glossinessM, "M", rect: layout.Inset(layout.fieldSize / 2), fieldSize: 0.81f);

            layout.Par(5);
            layout.margin -= 5; layout.rightMargin -= 5;
        }