Ray

PowenKo, Unity Tutorial b36-2, Ray Menu

December 30, 2011   ·   0 Comments

Screen Shot 2011-12-29 at 9.33.18 PM

using UnityEngine;
using System.Collections;

public class MenuFunction : MonoBehaviour {
	private string m_GameObjectName="";

	void Update () {
		if(Input.GetMouseButtonDown(0)){
		            Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		            RaycastHit hit;
		            if (Physics.Raycast (ray, out hit, 100)) {
			            GameObject Object_GameLogic=hit.collider.gameObject;        
						m_GameObjectName=Object_GameLogic.name+" ButtonDown";
		            }	
		}
		if(Input.GetMouseButtonUp(0)){
			  Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		            RaycastHit hit;
		            if (Physics.Raycast (ray, out hit, 100)) {	            
			            GameObject Object_GameLogic=hit.collider.gameObject;	        
						m_GameObjectName=Object_GameLogic.name+" ButtonUp";
		            }	
		}
	}
	//
	void OnGUI(){		
	       GUI.Label(new Rect (0,0, 100,20), m_GameObjectName);
	}
}

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon