public class EventManager : MonoBehaviour { public delegate void ClickAction(); public static event ClickAction OnClicked; void OnGUI() { if(GUI.Button(new Rect(Screen.width / 2 - 50, 5, 100, 30), "Click")) { if(OnClicked != null) OnClicked(); } } }
—————
using UnityEngine; using System.Collections; public class TeleportScript : MonoBehaviour { void OnEnable() { EventManager.OnClicked += Teleport; } void OnDisable() { EventManager.OnClicked -= Teleport; } void Teleport() { Vector3 pos = transform.position; pos.y = Random.Range(1.0f, 3.0f); transform.position = pos; } }
GazePointerRing - UnityEngine.Transform - ParticleGazeCursor - OVRGazePointer Cursor0 - UnityEngine.Transform Quad - UnityEngine.Transform - UnityEngine.MeshFilter - UnityEngine.MeshRenderer Half - UnityEngine.Transform - UnityEngine.ParticleSystemRenderer - UnityEngine.ParticleSystem Full - UnityEngine.Transform - UnityEngine.ParticleSystemRenderer - UnityEngine.ParticleSystem Cursor1 - UnityEngine.Transform Quad - UnityEngine.Transform - UnityEngine.MeshFilter - UnityEngine.MeshRenderer Half - UnityEngine.Transform - UnityEngine.ParticleSystemRenderer - UnityEngine.ParticleSystem Full - UnityEngine.Transform - UnityEngine.ParticleSystemRenderer - UnityEngine.ParticleSystem ARPort - UnityEngine.Transform - UnityEngine.MeshFilter - UnityEngine.MeshCollider - UnityEngine.MeshRenderer - Button3D - ViewTrigger VR Mouse Look (Rotation) - UnityEngine.Transform VR Mouse Look (Forward) - UnityEngine.Transform OVRCameraRig - UnityEngine.Transform - OVRCameraRig - OVRManager - VRMouseLook TrackingSpace - UnityEngine.Transform LeftEyeAnchor - UnityEngine.Transform CenterEyeAnchor - UnityEngine.Transform - UnityEngine.AudioListener - UnityEngine.Camera - Vuforia.HideExcessAreaBehaviour - Vuforia.VideoBackgroundBehaviour - VRIntegrationHelper CenterEyeAnchor - UnityEngine.Transform CenterEyeAnchor - UnityEngine.Transform - UnityEngine.MeshRenderer - Vuforia.BackgroundPlaneBehaviour - UnityEngine.MeshFilter CenterEyeAnchor - UnityEngine.Transform - UnityEngine.MeshFilter - UnityEngine.MeshRenderer RightEyeAnchor - UnityEngine.Transform TrackerAnchor - UnityEngine.Transform LeftHandAnchor - UnityEngine.Transform RightHandAnchor - UnityEngine.Transform CenterRightEyeAnchor - UnityEngine.Transform - UnityEngine.AudioListener - UnityEngine.Camera - VRIntegrationHelper - Vuforia.VideoBackgroundBehaviour - Vuforia.HideExcessAreaBehaviour CenterRightEyeAnchor - UnityEngine.Transform - UnityEngine.MeshFilter - UnityEngine.MeshRenderer VuforiaCenterAnchor - UnityEngine.Transform 2 GraphTrace_0 - UnityEngine.RectTransform - Vectrosity.VectorObject3D - UnityEngine.MeshRenderer - UnityEngine.MeshFilter 3 GraphTrace_1 - UnityEngine.RectTransform - Vectrosity.VectorObject3D - UnityEngine.MeshRenderer - UnityEngine.MeshFilter 4 GraphTrace_2 - UnityEngine.RectTransform - Vectrosity.VectorObject3D - UnityEngine.MeshRenderer - UnityEngine.MeshFilter 5 TextureBufferCamera - UnityEngine.Transform - UnityEngine.Camera TextureBufferMesh - UnityEngine.Transform - UnityEngine.MeshFilter - UnityEngine.MeshRenderer 6 TickMarks - UnityEngine.RectTransform - Vectrosity.VectorObject3D - UnityEngine.MeshRenderer - UnityEngine.MeshFilter