public override void OnInspectorGUI()
        {
#if UNITY_5_6_OR_NEWER
            serializedObject.UpdateIfRequiredOrScript();
#else
            serializedObject.UpdateIfDirtyOrScript();
#endif
            if (titleLabelStyle == null)
            {
                titleLabelStyle = new GUIStyle(EditorStyles.label);
            }
            titleLabelStyle.normal.textColor = titleColor;
            titleLabelStyle.fontStyle        = FontStyle.Bold;
            EditorGUIUtility.labelWidth      = 130;

            EditorGUILayout.Separator();
            GUILayout.Label("Rendering", titleLabelStyle);
            EditorGUILayout.IntPopup(renderType, renderTypesNames, renderTypesValues);
            RenderType rt = (RenderType)renderType.intValue;
            EditorGUILayout.IntPopup(weaponType, weaponTypesNames, weaponTypesValues);
            WeaponType wt = (WeaponType)weaponType.intValue;
            EditorGUILayout.HelpBox(GetRenderTypeDescription(rt), MessageType.Info);
            bool showTextureFields = !overrideMaterial.boolValue || !texturesByMaterial.boolValue;
            if (textureSample.objectReferenceValue == null && textureSide.objectReferenceValue != null)
            {
                textureSample.objectReferenceValue = textureSide.objectReferenceValue;
            }
            switch (rt)
            {
            case RenderType.Custom:
                EditorGUILayout.PropertyField(model, new GUIContent("Prefab", "Assign a prefab. Make sure your prefab uses a valid material (you can copy one of the VP Model * materials provided with Voxel Play). Please check the documentation for details."));
                EditorGUILayout.PropertyField(prefabMaterial, new GUIContent("Material", "The material to use when rendering the custom voxel. You can use the material provided by the prefab or use one of the optimized materials provided by Voxel Play."));
                EditorGUILayout.PropertyField(offset);
                EditorGUILayout.PropertyField(offsetRandom);
                if (offsetRandom.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(offsetRandomRange, new GUIContent("Offset Range", "Scale applied to random on each axis."));
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.PropertyField(scale);
                EditorGUILayout.PropertyField(rotation);
                EditorGUILayout.PropertyField(rotationRandomY);
                TextureField(textureSample, "Texture Sample", "Texture that represents the object colors. Used for sampling particle colors and inventory.");
                EditorGUILayout.PropertyField(opaque, new GUIContent("Opaque", "Set this value to 15 to specify that this is a fully solid object that occludes other adjacent voxels. A lower value let light pass through and reduces it by this amount. 0 = fully transparent."));
                EditorGUILayout.PropertyField(gpuInstancing, new GUIContent("GPU Instancing", "Uses GPU instancing to render the model."));
                if (gpuInstancing.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(castShadows, new GUIContent("Cast Shadows", "If this instanced voxel can cast shadows."));
                    EditorGUILayout.PropertyField(receiveShadows, new GUIContent("Receive Shadows", "If this instanced voxel can cast shadows."));
                    EditorGUILayout.PropertyField(createGameObject, new GUIContent("Create GameObject", "When GPU instancing is enabled, the rendering will be done in GPU but you can still force the creation of a gameobject which can hold colliders or custom scripts."));
                    EditorGUI.indentLevel--;
                }
                break;

            case RenderType.OpaqueNoAO:
            case RenderType.Opaque:
            case RenderType.OpaqueAnimated:
            case RenderType.Cloud:
            case RenderType.Cutout:
            case RenderType.Water:
                if (showTextureFields)
                {
                    TextureField(textureTop);
                    if (rt == RenderType.Opaque)
                    {
                        EditorGUI.indentLevel++;
                        TextureField(textureTopEmission, "Emission Mask");
                        EditorGUI.indentLevel--;
                    }
                    EditorGUI.indentLevel++;
                    TextureField(textureTopNRM, "Normal Map");
                    TextureField(textureTopDISP, "Displacement Map");
                    EditorGUI.indentLevel--;
                    TextureField(textureSide);
                    if (textureSide.objectReferenceValue != textureTop.objectReferenceValue)
                    {
                        if (rt.supportsEmission())
                        {
                            EditorGUI.indentLevel++;
                            TextureField(textureSideEmission, "Emission Mask");
                            EditorGUI.indentLevel--;
                        }
                        EditorGUI.indentLevel++;
                        TextureField(textureSideNRM, "Normal Map");
                        TextureField(textureSideDISP, "Displacement Map");
                        EditorGUI.indentLevel--;
                    }
                    TextureField(textureBottom);
                    if (textureBottom.objectReferenceValue != textureTop.objectReferenceValue && textureBottom.objectReferenceValue != textureSide.objectReferenceValue)
                    {
                        if (rt.supportsEmission())
                        {
                            EditorGUI.indentLevel++;
                            TextureField(textureBottomEmission, "Emission Mask");
                            EditorGUI.indentLevel--;
                        }
                        EditorGUI.indentLevel++;
                        TextureField(textureBottomNRM, "Normal Map");
                        TextureField(textureBottomDISP, "Displacement Map");
                        EditorGUI.indentLevel--;
                    }
                }
                if (rt == RenderType.Water)
                {
                    EditorGUILayout.PropertyField(showFoam);
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(tintColor);
                    if (!EditorGUI.EndChangeCheck())
                    {
                        CheckTintColorFeature();
                    }
                }
                break;

            case RenderType.Opaque6tex:
            case RenderType.Transp6tex:
                if (showTextureFields)
                {
                    TextureField(textureTop);
                    if (rt.supportsEmission())
                    {
                        EditorGUI.indentLevel++;
                        TextureField(textureTopEmission, "Emission Mask");
                        EditorGUI.indentLevel--;
                    }
                    EditorGUI.indentLevel++;
                    TextureField(textureTopNRM, "Normal Map");
                    TextureField(textureTopDISP, "Displacement Map");
                    EditorGUI.indentLevel--;
                    TextureField(textureBottom);
                    if (textureBottom.objectReferenceValue != textureTop.objectReferenceValue)
                    {
                        if (rt.supportsEmission())
                        {
                            EditorGUI.indentLevel++;
                            TextureField(textureBottomEmission, "Emission Mask");
                            EditorGUI.indentLevel--;
                        }
                        EditorGUI.indentLevel++;
                        TextureField(textureBottomNRM, "Normal Map");
                        TextureField(textureBottomDISP, "Displacement Map");
                        EditorGUI.indentLevel--;
                    }
                    TextureField(textureSide, "Texture Back");
                    if (textureSide.objectReferenceValue != textureTop.objectReferenceValue)
                    {
                        if (rt.supportsEmission())
                        {
                            EditorGUI.indentLevel++;
                            TextureField(textureSideEmission, "Emission Mask");
                            EditorGUI.indentLevel--;
                        }
                        EditorGUI.indentLevel++;
                        TextureField(textureSideNRM, "Normal Map");
                        TextureField(textureSideDISP, "Displacement Map");
                        EditorGUI.indentLevel--;
                    }
                    TextureField(textureRight, "Texture Right");
                    if (textureRight.objectReferenceValue != textureTop.objectReferenceValue)
                    {
                        if (rt.supportsEmission())
                        {
                            EditorGUI.indentLevel++;
                            TextureField(textureRightEmission, "Emission Mask");
                            EditorGUI.indentLevel--;
                        }
                        EditorGUI.indentLevel++;
                        TextureField(textureRightNRM, "Normal Map");
                        TextureField(textureRightDISP, "Displacement Map");
                        EditorGUI.indentLevel--;
                    }
                    TextureField(textureForward, "Texture Forward");
                    if (textureForward.objectReferenceValue != textureTop.objectReferenceValue)
                    {
                        if (rt.supportsEmission())
                        {
                            EditorGUI.indentLevel++;
                            TextureField(textureForwardEmission, "Emission Mask");
                            EditorGUI.indentLevel--;
                        }
                        EditorGUI.indentLevel++;
                        TextureField(textureForwardNRM, "Normal Map");
                        TextureField(textureForwardDISP, "Displacement Map");
                        EditorGUI.indentLevel--;
                    }
                    TextureField(textureLeft, "Texture Left");
                    if (textureLeft.objectReferenceValue != textureTop.objectReferenceValue)
                    {
                        if (rt.supportsEmission())
                        {
                            EditorGUI.indentLevel++;
                            TextureField(textureLeftEmission, "Emission Mask");
                            EditorGUI.indentLevel--;
                        }
                        EditorGUI.indentLevel++;
                        TextureField(textureLeftNRM, "Normal Map");
                        TextureField(textureLeftDISP, "Displacement Map");
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(tintColor);
                if (!EditorGUI.EndChangeCheck())
                {
                    CheckTintColorFeature();
                }
                if (renderType.intValue == (int)RenderType.Transp6tex)
                {
                    EditorGUILayout.PropertyField(alpha, new GUIContent("Alpha", "Custom alpha for transparent voxels. Texture alpha value is multipled by this factor."));
                }
                break;

            case RenderType.CutoutCross:
                TextureField(textureSide, "Texture");
                break;
            }
            if (rt == RenderType.Cutout || rt == RenderType.CutoutCross)
            {
                EditorGUILayout.PropertyField(colorVariation);
            }
            else if (rt == RenderType.OpaqueAnimated)
            {
                EditorGUILayout.PropertyField(animationTextures, new GUIContent("Additional Textures"), true);
                EditorGUILayout.PropertyField(animationSpeed, new GUIContent("Speed"));
            }
            if (rt != RenderType.Custom)
            {
                EditorGUILayout.PropertyField(overrideMaterial);
                if (overrideMaterial.boolValue)
                {
                    EditorGUILayout.HelpBox("Material shader must be compatible with the original VP shader.\nCheck the online documentation for more details.", MessageType.Info);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(overrideMaterialNonGeo, new GUIContent("Material", "Overriding material."));
                    if (GUILayout.Button("Locate Original"))
                    {
                        LocateOriginal(rt);
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.PropertyField(texturesByMaterial);
                    if (texturesByMaterial.boolValue)
                    {
                        EditorGUILayout.HelpBox("Shaders with name 'Voxel Play/Voxels/Override Examples/*** are examples you can use or duplicate.", MessageType.Info);
                    }
                }
            }
            EditorGUILayout.Separator();

            GUILayout.Label("Sound Effects", titleLabelStyle);
            EditorGUILayout.PropertyField(pickupSound);
            EditorGUILayout.PropertyField(buildSound);
            if (rt != RenderType.Cutout && rt != RenderType.CutoutCross && rt != RenderType.Water)
            {
                EditorGUILayout.PropertyField(footfalls, true);
            }
            EditorGUILayout.PropertyField(jumpSound);
            EditorGUILayout.PropertyField(landingSound);
            EditorGUILayout.PropertyField(impactSound);
            EditorGUILayout.PropertyField(destructionSound);

            EditorGUILayout.Separator();


            GUILayout.Label("Special Events", titleLabelStyle);
            EditorGUILayout.PropertyField(triggerWalkEvent);
            EditorGUILayout.PropertyField(triggerEnterEvent);

            EditorGUILayout.Separator();

            GUILayout.Label("Other Attributes", titleLabelStyle);
            EditorGUILayout.PropertyField(title);
            EditorGUILayout.PropertyField(resistancePoints);

            EditorGUILayout.PropertyField(hidden);
            if (!hidden.boolValue)
            {
                EditorGUILayout.PropertyField(canBeCollected);
                if (canBeCollected.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(dropItem);
                    EditorGUILayout.PropertyField(dropItemLifeTime);
                    EditorGUILayout.PropertyField(dropItemScale);
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.PropertyField(icon);

                if (rt.supportsTextureRotation())
                {
                    EditorGUILayout.PropertyField(allowsTextureRotation, new GUIContent("Can Rotate", "Allows texture/object rotation by using VoxelRotateTextures or VoxelRotate (for custom voxel) and similar methods."));
                    GUI.enabled = allowsTextureRotation.boolValue;
                    EditorGUILayout.PropertyField(placeFacingPlayer);
                    GUI.enabled = true;
                }

                EditorGUILayout.PropertyField(promotesTo);
            }
            EditorGUILayout.PropertyField(replacedBy);
            if (rt != RenderType.Cloud)
            {
                EditorGUILayout.PropertyField(biomeDirtCounterpart);
            }

            if (rt.supportsNavigation())
            {
                EditorGUILayout.PropertyField(navigatable);
            }

            if (rt.supportsWindAnimation())
            {
                EditorGUILayout.PropertyField(windAnimation);
            }
            if (rt == RenderType.Water)
            {
                EditorGUILayout.PropertyField(height);
                EditorGUILayout.PropertyField(diveColor);
                EditorGUILayout.PropertyField(spreads);
                if (spreads.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(spreadDelay);
                    EditorGUILayout.PropertyField(spreadDelayRandom);
                    EditorGUILayout.PropertyField(drains);
                    EditorGUI.indentLevel--;
                }
            }
            if (rt != RenderType.CutoutCross && rt != RenderType.Water && rt != RenderType.Empty && rt != RenderType.Cloud)
            {
                EditorGUILayout.PropertyField(triggerCollapse);
                EditorGUILayout.PropertyField(willCollapse);
            }

            EditorGUILayout.PropertyField(playerDamage);
            GUI.enabled = playerDamage.intValue > 0;
            EditorGUILayout.PropertyField(playerDamageDelay);
            GUI.enabled = true;

            EditorGUILayout.PropertyField(ignoresRayCast);
            if (!ignoresRayCast.boolValue)
            {
                EditorGUILayout.PropertyField(highlightOffset);
            }

            if (rt.supportsOptionalColliders())
            {
                EditorGUILayout.PropertyField(generateColliders);
            }

            if (rt.supportsAlphaSeeThrough())
            {
                EditorGUILayout.PropertyField(seeThroughMode);
                if (seeThroughMode.intValue == (int)SeeThroughMode.ReplaceVoxel)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(seeThroughVoxel, new GUIContent("Replace By", "The voxel used to render when see-through effect occurs. This voxel can be a variation of this voxel with transparency of any other type of voxel."));
                    EditorGUI.indentLevel--;
                }
            }
            EditorGUILayout.PropertyField(lightIntensity);
            EditorGUILayout.PropertyField(weaponLevel);

            serializedObject.ApplyModifiedProperties();
        }