修改调整
This commit is contained in:
40
Assets/Plugins/FairyGUI/Examples/HitTest/HitTestMain.cs
Normal file
40
Assets/Plugins/FairyGUI/Examples/HitTest/HitTestMain.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class HitTestMain : MonoBehaviour
|
||||
{
|
||||
Transform cube;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
|
||||
cube = GameObject.Find("Cube").transform;
|
||||
|
||||
Stage.inst.onTouchBegin.Add(OnTouchBegin);
|
||||
}
|
||||
|
||||
void OnTouchBegin()
|
||||
{
|
||||
if (!Stage.isTouchOnUI)
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = Camera.main.ScreenPointToRay(new Vector2(Stage.inst.touchPosition.x, Screen.height - Stage.inst.touchPosition.y));
|
||||
if (Physics.Raycast(ray, out hit))
|
||||
{
|
||||
if (hit.transform == cube)
|
||||
{
|
||||
Debug.Log("Hit the cube");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Plugins/FairyGUI/Examples/HitTest/HitTestMain.cs.meta
Normal file
12
Assets/Plugins/FairyGUI/Examples/HitTest/HitTestMain.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12542fe68a883624ea477c953ae0cf52
|
||||
timeCreated: 1456474677
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user