Last active
December 1, 2016 17:58
-
-
Save kazumalab/187949f43f66d7b2deb9cff780b425ef to your computer and use it in GitHub Desktop.
This file contains 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class PointerTest : MonoBehaviour { | |
private LineRenderer pointer; | |
private void Start () { | |
pointer = this.GetComponent<LineRenderer>(); | |
pointer.numPositions = 2; | |
} | |
private void Update () { | |
pointer.SetPosition (0, this.transform.position); | |
RaycastHit hit; | |
if (Physics.Raycast (this.transform.position, this.transform.forward * 10f, out hit, 100)) { | |
if (hit.collider.tag == "Point") { | |
pointer.SetPosition (1, hit.point); | |
EnablePointer (); | |
} else { | |
DisEnablePointer (); | |
} | |
} else { | |
DisEnablePointer (); | |
} | |
} | |
private void EnablePointer () { | |
pointer.enabled = true; | |
} | |
private void DisEnablePointer () { | |
pointer.enabled = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment