Beispiel #1
0
        private void PhysicsFieldsGUI(ref VerticalGUIRect guiRect, BlockData block)
        {
            block.Hardness     = EditorGUI.IntField(guiRect.Next, s_HardnessContent, block.Hardness);
            block.LightValue   = EditorGUI.IntSlider(guiRect.Next, s_LightValueContent, block.LightValue, 0, LightingUtility.MaxLight);
            block.LightOpacity = EditorGUI.IntSlider(guiRect.Next, s_LightOpacityContent, block.LightOpacity, 0, LightingUtility.MaxLight);
            block.PhysicState  = (PhysicState)EditorGUI.EnumPopup(guiRect.Next, s_PhysicStateContent, block.PhysicState);
            guiRect.Space(10);

            EditorGUI.LabelField(guiRect.Next, s_PhysicMaterialContent, EditorStyles.boldLabel);
            block.PhysicMaterial.CoefficientOfRestitution     = EditorGUI.Slider(guiRect.Next, s_CoefficientOfRestitutionContent, block.PhysicMaterial.CoefficientOfRestitution, 0, 1);
            block.PhysicMaterial.CoefficientOfStaticFriction  = EditorGUI.FloatField(guiRect.Next, s_CoefficientOfStaticFrictionContent, block.PhysicMaterial.CoefficientOfStaticFriction);
            block.PhysicMaterial.CoefficientOfDynamicFriction = EditorGUI.FloatField(guiRect.Next, s_CoefficientOfDynamicFrictionContent, block.PhysicMaterial.CoefficientOfDynamicFriction);
        }
Beispiel #2
0
        private void CommonFieldsGUI(ref VerticalGUIRect guiRect, BlockData block)
        {
            using (new EditorGUI.DisabledGroupScope(true))
            {
                EditorGUI.IntField(guiRect.Next, s_IDContent, block.ID);
            }

            block.InternalName = EditorGUI.TextField(guiRect.Next, s_InternalNameContent, block.InternalName);

            block.RewardItem       = EditorGUI.TextField(guiRect.Next, s_RewardItemContent, block.RewardItem);
            block.Flags            = (BlockFlags)EditorGUI.EnumFlagsField(guiRect.Next, s_FlagsContent, block.Flags);
            block.RotationAxes     = (BlockRotationAxes)EditorGUI.EnumFlagsField(guiRect.Next, s_RotationAxesContent, block.RotationAxes);
            block.EntityConversion = (BlockEntityConversion)EditorGUI.EnumPopup(guiRect.Next, s_EntityConversionContent, block.EntityConversion);
        }
Beispiel #3
0
        protected override void OnScrollableGUI(ref VerticalGUIRect rect, int index)
        {
            BlockData block = MainWnd.Blocks[index];

            switch (m_SelectedCategoryIndex)
            {
            case 0: CommonFieldsGUI(ref rect, block); break;

            case 1: PhysicsFieldsGUI(ref rect, block); break;

            case 2: RenderingFieldsGUI(ref rect, block); break;

            case 3: AudioFieldsGUI(ref rect, block); break;
            }
        }
Beispiel #4
0
        public bool OnGUI(Rect rect, int index)
        {
            Rect            initialRect = rect;
            VerticalGUIRect guiRect     = GetGUIRectWithMargin(ref rect);

            OnBeforeScrollableGUI(ref guiRect, index);

            Rect scrollViewRect = new Rect(initialRect.x, initialRect.y + guiRect.UsedHeight, initialRect.width, initialRect.height - guiRect.UsedHeight);

            m_ScrollPos = GUI.BeginScrollView(scrollViewRect, m_ScrollPos, m_LastRect);

            EditorGUI.BeginChangeCheck();
            OnScrollableGUI(ref guiRect, index);
            guiRect.Space(10);
            bool changed = EditorGUI.EndChangeCheck();

            GUI.EndScrollView();
            m_LastRect = new Rect(scrollViewRect.x, scrollViewRect.y, rect.xMax - scrollViewRect.x, guiRect.UsedHeight + scrollViewRect.height - initialRect.height);
            return(changed);
        }
Beispiel #5
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--;
                }
            }
        }
Beispiel #6
0
        protected override void OnScrollableGUI(ref VerticalGUIRect rect, int index)
        {
            BiomeData biome = MainWnd.Biomes[index];

            rect.Space(10);

            using (new EditorGUI.DisabledGroupScope(true))
            {
                EditorGUI.IntField(rect.Next, s_IDContent, biome.ID);
                EditorGUI.TextField(rect.Next, s_InternalNameContent, biome.InternalName);
            }

            biome.BaseHeight      = EditorGUI.FloatField(rect.Next, s_BaseHeightContent, biome.BaseHeight);
            biome.HeightVariation = EditorGUI.FloatField(rect.Next, s_HeightVariationContent, biome.HeightVariation);
            biome.Temperature     = EditorGUI.FloatField(rect.Next, s_TemperatureContent, biome.Temperature);
            biome.Rainfall        = EditorGUI.FloatField(rect.Next, s_RainfallContent, biome.Rainfall);
            biome.EnableSnow      = EditorGUI.Toggle(rect.Next, s_EnableSnowContent, biome.EnableSnow);
            biome.EnableRain      = EditorGUI.Toggle(rect.Next, s_EnableRainContent, biome.EnableRain);
            biome.TopBlock        = EditorGUI.TextField(rect.Next, s_TopBlockContent, biome.TopBlock);
            biome.FillerBlock     = EditorGUI.TextField(rect.Next, s_FillerBlockContent, biome.FillerBlock);

            biome.TreesPerChunk     = EditorGUI.IntField(rect.Next, s_TreesPerChunkContent, biome.TreesPerChunk);
            biome.ExtraTreeChance   = EditorGUI.FloatField(rect.Next, s_ExtraTreeChanceContent, biome.ExtraTreeChance);
            biome.GrassPerChunk     = EditorGUI.IntField(rect.Next, s_GrassPerChunkContent, biome.GrassPerChunk);
            biome.FlowersPerChunk   = EditorGUI.IntField(rect.Next, s_FlowersPerChunkContent, biome.FlowersPerChunk);
            biome.MushroomsPerChunk = EditorGUI.IntField(rect.Next, s_MushroomsPerChunkContent, biome.MushroomsPerChunk);

            biome.DeadBushPerChunk = EditorGUI.IntField(rect.Next, s_DeadBushPerChunkContent, biome.DeadBushPerChunk);
            biome.ReedsPerChunk    = EditorGUI.IntField(rect.Next, s_ReedsPerChunkContent, biome.ReedsPerChunk);
            biome.CactiPerChunk    = EditorGUI.IntField(rect.Next, s_CactiPerChunkContent, biome.CactiPerChunk);

            biome.ClayPerChunk          = EditorGUI.IntField(rect.Next, s_ClayPerChunkContent, biome.ClayPerChunk);
            biome.WaterlilyPerChunk     = EditorGUI.IntField(rect.Next, s_WaterlilyPerChunkContent, biome.WaterlilyPerChunk);
            biome.SandPatchesPerChunk   = EditorGUI.IntField(rect.Next, s_SandPatchesPerChunkContent, biome.SandPatchesPerChunk);
            biome.GravelPatchesPerChunk = EditorGUI.IntField(rect.Next, s_GravelPatchesPerChunkContent, biome.GravelPatchesPerChunk);
        }
Beispiel #7
0
 protected abstract void OnScrollableGUI(ref VerticalGUIRect rect, int index);
Beispiel #8
0
 protected virtual void OnBeforeScrollableGUI(ref VerticalGUIRect rect, int index)
 {
 }