05-17 06:36
Notice
Recent Posts
Recent Comments
관리 메뉴

Scientific Computing & Data Science

Script for an Object Clicked - an Alternative Method 본문

CG & Video Games/Unity 3D

Script for an Object Clicked - an Alternative Method

cinema4dr12 2013. 5. 26. 12:20

using UnityEngine;

using System.Collections;

 

public class ObjectClicked2 : MonoBehaviour {

Ray myray = new Ray();

RaycastHit myhit = new RaycastHit();

 

// Use this for initialization

void Start () {

}

 

// Update is called once per frame

void Update () {

myray = Camera.main.ScreenPointToRay(Input.mousePosition);

 

if (Physics.Raycast(myray, out myhit, 1000.0f) && Input.GetMouseButtonDown(0))

print(myhit.collider.name);

}

}

'CG & Video Games > Unity 3D' 카테고리의 다른 글

How to Play Animation Sequence in Unity  (0) 2013.05.26
Script for an Object Touched on Mobile Devices  (0) 2013.05.26
Script for an Object Clicked  (0) 2013.05.26
Script for Mobile Touch Scree  (0) 2013.05.26
Fetching IP Address in C#  (0) 2013.05.26
Comments