コード例 #1
0
    void HifhLightFunction()
    {
        //循环往复外发光开启(参数为:颜色1,颜色2,切换时间)
        m_ho.FlashingOn(Color.green, Color.blue, 1f);

        //关闭循环往复外发光
        m_ho.FlashingOff();


        //持续外发光开启(参数:颜色)
        m_ho.ConstantOn(Color.yellow);

        //关闭持续外发光
        m_ho.ConstantOff();
    }
コード例 #2
0
    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);
    }
コード例 #3
0
 void Awake()
 {
     //初始化组件
     m_ho = GetComponent <HighlightableObject>();
     m_ho.FlashingOn(Color.green, Color.gray, 1f);
     //m_ho.FlashingOn(Color.gray,Color.green);
     //m_ho.FlashingParams(Color.green,Color.gray, 1f);
     //m_ho.FlashingSwitch();
 }
コード例 #4
0
ファイル: CameraTargeting.cs プロジェクト: hzbaba/Assets
    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);
            }
        }
    }
コード例 #5
0
 /// <summary>
 /// 显示高亮
 /// </summary>
 /// <param name="flashing">是否为闪烁</param>
 public void SetHighLighting(bool flashing)
 {
     if (flashing)
     {
         //闪烁
         _hlObj.FlashingOn(Color.red, Color.green, 2);
     }
     else
     {
         //常亮
         _hlObj.ConstantOn(Color.black);
     }
 }
コード例 #6
0
 // Start is called before the first frame update
 void Start()
 {
     //slider.ConstantOn(Color.yellow);
     //slider.ConstantOff();
     slider.FlashingOn(Color.green, Color.yellow, 1f);
 }