I’m building a custom editor and would like to control the transform with an IntSlider and/or (int * float) calculations but all attempts have failed… This code executes fine in MonoDevelop but bombs out in Unity for ‘type is not supported int value’. I understand why this does not work… what I need help/guidance with is getting the functionality I am looking for. Thanks!
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Transform)), CanEditMultipleObjects]
public class testTranspose2 : Editor
{
private SerializedObject m_object;
private SerializedProperty m_propPosition;
private void OnEnable()
{
m_object = new SerializedObject(target);
m_propPosition = m_object.FindProperty("m_LocalPosition.x");
}
public override void OnInspectorGUI()
{
m_object.Update();
EditorGUILayout.IntSlider(m_propPosition,0,9);
m_object.ApplyModifiedProperties();
}
}
Try: m_propPosition.intValue = EditorGUILayout.IntSlider(m_propPosition.intValue,0,9); Regarding
– Chronos-Lm_propPosition = m_object.FindProperty("m_LocalPosition.x");, will this line work, it will extract thetransform.localPosition.x? I have never seen anything like this before (just to put it out there, I am not doubting about this line, I am just asking because I just don't know)Is it possible that
– Chronos-L.floatValuewill work becausetransform.localPosition.xis float, not int?