How to make my own Transform inspector without using a Custom Inspector to override Transform ?

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);

    }
}

Sure
if you want position inspector = position you move gameobject on scene, you need add update position current into your custom inspector

 void OnEnable()
    {
         CustomTranform myTarget  = (CustomTranform)target;
         x = myTarget.position.x;
         y = myTarget.position.y;
         z = myTarget.position.z;
    }

void OnEnable will be called when gameobject selected

Thsanks man. I think this will helpme with my custom editor.