void SelectTarget() { if (Input.GetMouseButtonDown(1)) //on right click... { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) //do a raycast... { ManagerPointer p = hit.collider.gameObject.GetComponent <ManagerPointer> (); if (p != null) //if the object can be rewound... { if (overseer == p.GetOverseer()) //if the object is already the selected object... //unpause and release { Clear(); } else if (overseer == null) //if no object is selected... //add and pause { Select(p); } else //if some other object is selected... { Clear(); //unpause and deselect the old object Select(p); //and add and pause the new object } } } } }
//does a raycast along transform.forward and tries to find a ManagerPointer on the target. Returns the associated overseer. RewindOverseer RaycastForRewinder() { Ray ray = new Ray(transform.position, transform.forward); RaycastHit hit; ManagerPointer p = null; if (Physics.Raycast(ray, out hit, 100)) //do a raycast... { p = hit.collider.gameObject.GetComponent <ManagerPointer> (); } return(p == null ? null : p.GetOverseer()); }
//make a manager pointer so that this object knows what's managing it void CreateOverseerPointer() { pointer = gameObject.AddComponent <ManagerPointer>(); pointer.SetManager(overseer); }
void Select(ManagerPointer p) { scrollBuffer = 0f; overseer = p.GetOverseer(); PauseObject(overseer); }