Last active
June 1, 2016 10:04
-
-
Save uhziel/5749767 to your computer and use it in GitHub Desktop.
Unity3D script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
[ExecuteInEditMode] | |
public class LookAtPoint : MonoBehaviour { | |
public Vector3 lookAtPoint = Vector3.zero; | |
// Update is called once per frame | |
void Update () { | |
transform.LookAt (lookAtPoint); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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