Hi guys ,
I am creating a script custom Transform component which I place on my objects . I do not wish to use a custom Inspector to override Transform.
I can set the position of my objects from the inspector but when i move the object in the scene and stop dragging it , the object moves back to the position I had set in my custom transform inspector.
here is my script :
using UnityEngine;
[ExecuteInEditMode]
public class CustomTransform : MonoBehaviour {
public Vector3 position
{
get
{
return transform.position;
}
set
{
transform.position = new value;
}
}
}
This is where i will now use my own CustomInspector to target the CustomTransform script and draw the GUI.
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(CustomTransform))]
public class CustomTransformInspector : Editor
{
private float x, y, z;
public override void OnInspectorGUI()
{
CustomTransform myTarget = (CustomTransform)target;
x = EditorGUILayout.FloatField("X", x);
y = EditorGUILayout.FloatField("Y", y);
z = EditorGUILayout.FloatField("Z", z);
myTarget.position = new Vector3(x, y, z);
}
}