public void AddTarget(OutLineTargetComponent target)
    {
        if (target.material == null)
        {
            target.material = new Material(preoutlineShader);
        }
        targetObjects.Add(target);

        RefreshCommandBuff();
    }
Example #2
0
    public void AddTarget(OutLineTargetComponent target)
    {
        if (target.material == null)
        {
            target.material = new Material(preoutlineShader);
        }

        //Debug.Log(target.material);
        //Debug.Log(target.gameObject.name);
        targetObjects.Add(target);

        RefreshCommandBuff();
    }
Example #3
0
    private void Awake()
    {
        //改变层级
        foreach (var item in transform.GetComponentsInChildren <Transform>())
        {
            if (!item.GetComponentInParent <Canvas>())
            {
                item.gameObject.layer = LayerMask.NameToLayer("Instrument");
            }
        }

        mState                 = State.normal;
        rig                    = gameObject.GetComponent <Rigidbody>();
        greenMaterial          = (Material)ResMgr.Instance.LoadByCore("Material/GreenMaterial");
        redMaterial            = (Material)ResMgr.Instance.LoadByCore("Material/RedMaterial");
        outLineTargetComponent = gameObject.GetComponent <OutLineTargetComponent>();
        if (outLineTargetComponent == null)
        {
            outLineTargetComponent = gameObject.AddComponent <OutLineTargetComponent>();
        }
        offsetZ = MinOffsetZ;

        renderers = transform.GetComponentsInChildren <Renderer>(true);
        for (int i = 0; i < renderers.Length; i++)
        {
            materials.Add(renderers[i].materials);
        }
        colliders = transform.GetComponentsInChildren <Collider>(true).ToList();
        //如果是按键的碰撞盒,移除
        for (int i = colliders.Count - 1; i >= 0; i--)
        {
            if (colliders[i].GetComponentInParent <mButton>() != null)
            {
                colliders.Remove(colliders[i]);
            }
        }
        if (adsorbCollider)
        {
            adsorbCollider.enabled   = false;
            adsorbCollider.isTrigger = true;
            adsorbTypeList           = null;
            colliders.Remove(adsorbCollider);
        }
        SetState(State.normal);
        Messenger.AddListener <Collider, string>(GlobalEvent.Player_Selected_Instrument, SelectedInsturment);
        SetRenderer(HeldState.normal);
        CanScaleInstrument = true;
        AwakeLater();
    }
Example #4
0
    public void RemoveTarget(OutLineTargetComponent target)
    {
        bool found = false;

        for (int i = 0; i < targetObjects.Count; i++)
        {
            if (targetObjects[i] == target)
            {
                targetObjects.Remove(target);
                DestroyImmediate(target.material);
                target.material = null;
                found           = true;
                break;
            }
        }

        if (found)
        {
            RefreshCommandBuff();
        }
    }