30 lines
821 B
C#
30 lines
821 B
C#
|
using System;
|
|||
|
|
|||
|
using UnityEngine;
|
|||
|
using UnityEditor;
|
|||
|
|
|||
|
|
|||
|
namespace AmazingAssets.CurvedWorldEditor
|
|||
|
{
|
|||
|
public class CurvedWorldToggleFloatDrawer : MaterialPropertyDrawer
|
|||
|
{
|
|||
|
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor)
|
|||
|
{
|
|||
|
// Setup
|
|||
|
bool value = (prop.floatValue > 0.5f);
|
|||
|
|
|||
|
EditorGUI.BeginChangeCheck();
|
|||
|
EditorGUI.showMixedValue = prop.hasMixedValue;
|
|||
|
|
|||
|
// Show the toggle control
|
|||
|
value = EditorGUI.Toggle(position, label, value);
|
|||
|
|
|||
|
EditorGUI.showMixedValue = false;
|
|||
|
if (EditorGUI.EndChangeCheck())
|
|||
|
{
|
|||
|
// Set the new value if it has changed
|
|||
|
prop.floatValue = value ? 1.0f : 0.0f;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|