예제 #1
0
    private void ColorStartAndFinish(Informer start, Informer finish)
    {
        if (_startRenderer != null)
        {
            _startRenderer.material.SetColor("_Color", _startColor);
        }

        StartInformer  = start;
        _startRenderer = StartInformer.GetComponent <Renderer>();
        _startColor    = _startRenderer.material.GetColor("_Color");
        _startRenderer.material.SetColor("_Color", Color.cyan);

        Debug.Log("Start" + StartInformer.transform.position);

        if (_finishRenderer != null)
        {
            _finishRenderer.material.SetColor("_Color", _finishColor);
        }

        FinishInformer  = finish;
        _finishRenderer = FinishInformer.GetComponent <Renderer>();
        _finishColor    = _finishRenderer.material.GetColor("_Color");
        _finishRenderer.material.SetColor("_Color", Color.magenta);

        Debug.Log("Finish" + FinishInformer.transform.position);
    }
예제 #2
0
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            RaycastHit hit;
            var        cam = FindObjectOfType <Camera>();
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                var tile = hit.collider.gameObject;
                if (!_startChanged)
                {
                    _startChanged = true;
                    if (_startRenderer != null)
                    {
                        _startRenderer.material.SetColor("_Color", _startColor);
                    }

                    StartInformer  = tile.GetComponent <Informer>();
                    _startRenderer = StartInformer.GetComponent <Renderer>();
                    _startColor    = _startRenderer.material.GetColor("_Color");
                    _startRenderer.material.SetColor("_Color", Color.cyan);

                    Debug.Log("Start" + StartInformer.transform.position);
                }
                else
                {
                    _startChanged = false;
                    if (_finishRenderer != null)
                    {
                        _finishRenderer.material.SetColor("_Color", _finishColor);
                    }

                    FinishInformer  = tile.GetComponent <Informer>();
                    _finishRenderer = FinishInformer.GetComponent <Renderer>();
                    _finishColor    = _finishRenderer.material.GetColor("_Color");
                    _finishRenderer.material.SetColor("_Color", Color.magenta);

                    Debug.Log("Finish" + FinishInformer.transform.position);
                }
            }
        }
    }