Beispiel #1
0
        private void RenderingFieldsGUI(ref VerticalGUIRect guiRect, BlockData block)
        {
            MainWnd.BlockMeshes.ElementGUI(guiRect.Next, s_MeshContent, ref block.Mesh);

            AssetPtr  meshPtr = MainWnd.BlockMeshes[block.Mesh];
            BlockMesh mesh    = EditorAssetUtility.LoadAssetByGUID <BlockMesh>(meshPtr.AssetGUID);

            if (!mesh)
            {
                EditorGUI.HelpBox(guiRect.GetNext(40, true, true), "You should assign an empty mesh if you do not want this block to be rendered.", MessageType.Error);
            }
            else if (mesh.Faces.Length == 0)
            {
                EditorGUI.HelpBox(guiRect.GetNext(40, true, true), "This block will never be rendered.", MessageType.Warning);
            }
            else
            {
                MainWnd.BlockMaterials.ElementGUI(guiRect.Next, s_MaterialContent, ref block.Material);

                BlockMesh.FaceData[] faces = mesh.Faces;
                ArrayUtility.EnsureArrayReferenceAndSize(ref block.Textures, faces.Length, true);

                for (int i = 0; i < faces.Length; i++)
                {
                    BlockFace face = faces[i].Face;
                    EditorGUI.LabelField(guiRect.Next, face.ToString(), EditorStyles.boldLabel);

                    ArrayUtility.EnsureArrayReferenceAndSize(ref block.Textures[i], 3, true);

                    EditorGUI.indentLevel++;
                    for (int j = 0; j < 3; j++)
                    {
                        MainWnd.BlockTextures.ElementGUI(guiRect.Next, s_TextureContents[j], ref block.Textures[i][j]);
                    }
                    EditorGUI.indentLevel--;
                }
            }
        }