Hi, is there a way to detect when a gameobject is moved within the Editor?
Use to detect when something is moved.
Put this into a script which you then assign to the object you want to detect:
using UnityEngine;
using System.Collections;
public class PlayerComponent1 : MonoBehaviour {
Vector3 getPos = Vector3.zero;
void Start () {
}
// Update is called once per frame
void Update () {
Debug.Log (this.transform.hasChanged);
getPos = this.transform.position;
StartCoroutine (WaitAndCheck(0.1f));
}
IEnumerator WaitAndCheck(float waittime){
yield return new WaitForSeconds(waittime);
if (getPos == this.transform.position) {
this.transform.hasChanged = false;
Debug.Log (this.transform.hasChanged);
} else {
Debug.Log (this.transform.hasChanged);
}
}
}
and to check for it :
using UnityEngine;
using System.Collections;
public class TestForMovement : MonoBehaviour {
void Start () {
}
// Update is called once per frame
void Update () {
if(yourgameobjectnamehere.transform.hasChanged)
//GAMEOBJECT is moving!
//Do Code
} else {
//GAMEOBJECT isn't moving!
}
}
On the right side, in the inspector, looks like this - http://data.fuskbugg.se/skalman02/4d88fd2668310_cube.jpg Select the object you want, if the numbers on X,Y or Z changes, the object is moving.
Maybe i missunderstood you question?
If you mean in a script, you can enable scripts to run in the editor http://unity3d.com/support/documentation/ScriptReference/ExecuteInEditMode.html
It looks like there's no way to do this in Unity. I've worked around this problem by making the gizmo rendering use Local coords.