Skip to content

Instantly share code, notes, and snippets.

@uhziel
Last active June 1, 2016 10:04
Show Gist options
  • Save uhziel/5749767 to your computer and use it in GitHub Desktop.
Save uhziel/5749767 to your computer and use it in GitHub Desktop.
Unity3D script
using UnityEngine;
[ExecuteInEditMode]
public class LookAtPoint : MonoBehaviour {
public Vector3 lookAtPoint = Vector3.zero;
// Update is called once per frame
void Update () {
transform.LookAt (lookAtPoint);
}
}
using UnityEngine;
using UnityEditor;
[CustomEditor (typeof(LookAtPoint))]
public class LookAtPointEditor : Editor {
// Update is called once per frame
public override void OnInspectorGUI () {
LookAtPoint _target = (LookAtPoint)target;
_target.lookAtPoint = EditorGUILayout.Vector3Field ("Look At Point:", _target.lookAtPoint);
if (GUI.changed) {
EditorUtility.SetDirty(_target);
}
}
void OnSceneGUI () {
LookAtPoint _target = (LookAtPoint)target;
_target.lookAtPoint = Handles.PositionHandle(_target.lookAtPoint, Quaternion.identity);
if (GUI.changed) {
EditorUtility.SetDirty(_target);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment