Esempio n. 1
0
    void DisplayRegion(RegionData region, int index)
    {
        EditorGUILayout.BeginVertical("box");

        region.name   = EditorGUILayout.TextField("Name", region.name);
        region.height = EditorGUILayout.Slider("Height", region.height, 0f, 1f);

        if (useTextures)
        {
            GUILayout.Space(8);
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label("Main texture");
            region.mainTexture = (Texture2D)EditorGUILayout.ObjectField(region.mainTexture, typeof(Texture2D), false, GUILayout.Width(80), GUILayout.Height(80));
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label("Slope texture");
            region.slopeTexture = (Texture2D)EditorGUILayout.ObjectField(region.slopeTexture, typeof(Texture2D), false, GUILayout.Width(80), GUILayout.Height(80));
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            region.scale = EditorGUILayout.FloatField("Scale", region.scale);
            GUILayout.Space(10);
        }

        region.colorStrenght     = EditorGUILayout.Slider("Color strenght", region.colorStrenght, 0f, 1f);
        region.mainColor         = EditorGUILayout.ColorField("Main color", region.mainColor);
        region.slopeColor        = EditorGUILayout.ColorField("Slope color", region.slopeColor);
        region.slopeThreshold    = EditorGUILayout.Slider("Slope threshold", region.slopeThreshold, 0f, 1f);
        region.slopeBlendAmount  = EditorGUILayout.Slider("Slope blend amount", region.slopeBlendAmount, 0f, 1f);
        region.regionBlendAmount = EditorGUILayout.Slider("Region blend amount", region.regionBlendAmount, 0f, 0.5f);

        GUILayout.Space(15);

        EditorGUILayout.BeginHorizontal();

        if (index > 0)
        {
            if (GUILayout.Button("Up", GUILayout.Width(50)))
            {
                serializableObject.SwapRegionUp(index);
            }
        }
        else
        {
            GUILayout.Space(52);
        }

        if (index < regionCount - 1)
        {
            if (GUILayout.Button("Down", GUILayout.Width(50)))
            {
                serializableObject.SwapRegionDown(index);
            }
        }
        else
        {
            GUILayout.Space(52);
        }

        GUILayout.Space(Screen.width - 200);


        if (GUILayout.Button("Delete", GUILayout.Width(50)))
        {
            serializableObject.DeleteRegion(region);
            return;
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndVertical();
    }