void HifhLightFunction() { //循环往复外发光开启(参数为:颜色1,颜色2,切换时间) m_ho.FlashingOn(Color.green, Color.blue, 1f); //关闭循环往复外发光 m_ho.FlashingOff(); //持续外发光开启(参数:颜色) m_ho.ConstantOn(Color.yellow); //关闭持续外发光 m_ho.ConstantOff(); }
public void setTarget(Transform targetTransform) { if (lasttargetTransform != null) { HighlightableObject targetho = lasttargetTransform.GetComponent <HighlightableObject>(); targetho.FlashingOff(); lasttargetTransform = null; } if (targetTransform == null) { return; } HighlightableObject ho = targetTransform.GetComponent <HighlightableObject>(); if (ho == null) { return; } lasttargetTransform = targetTransform; // Start flashing with frequency = 2 ho.FlashingOn(2f); GameEntityCtrl ge = lasttargetTransform.gameObject.GetComponent <GameEntityCtrl>(); TargetManger.setTarget(ge.seo); }
public void TargetingRaycast() { // Current mouse position on screen Vector3 mp = Input.mousePosition; // Current target object transform component Transform targetTransform = null; // If camera component is available if (cam != null) { RaycastHit hitInfo; // Create a ray from mouse coords Ray ray = cam.ScreenPointToRay(new Vector3(mp.x, mp.y, 0f)); // Targeting raycast if (Physics.Raycast(ray.origin, ray.direction, out hitInfo, targetingRayLength, targetingLayerMask.value)) { // Cache what we've hit targetTransform = hitInfo.collider.transform; } } // If we've hit an object during raycast if (targetTransform != null) { // And this object has HighlightableObject component HighlightableObject ho = targetTransform.root.GetComponentInChildren <HighlightableObject>(); if (ho != null) { // If left mouse button down if (Input.GetButtonDown("Fire1")) { // Start flashing with frequency = 2 ho.FlashingOn(2f); } // If right mouse button is up if (Input.GetButtonUp("Fire2")) { // Stop flashing ho.FlashingOff(); } // If middle mouse button is up if (Input.GetButtonUp("Fire3")) { // Switch flashing ho.FlashingSwitch(); } // One-frame highlighting (to highlight an object which is currently under mouse cursor) ho.On(Color.red); } } }
/// <summary> /// 关闭闪烁 /// </summary> /// <param name="go"></param> public void FlashOff(GameObject go) { HighlightableObject ho = go.GetComponent <HighlightableObject>(); if (ho != null) { //Debug.Log("flash off " + ho.name); ho.FlashingOff(); } }