Esempio n. 1
0
    public void reset()
    {
        if (selected)
        {
            rend.material.shader = shader1;
            MoveBody MoveBody = selected.GetComponent <MoveBody>();
            MoveBody.enabled = false;
        }

        isSelected = false;
        selected   = null;
        rend       = null;
    }
Esempio n. 2
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0)) // LMB
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                if (hit.transform != null && hit.transform.gameObject.tag == "Movable")
                {
                    reset();

                    PrintName(hit.transform.gameObject);

                    if (rb = hit.transform.GetComponent <Rigidbody>())
                    {
                        isSelected = true;
                        selected   = hit.transform.gameObject;
                        rend       = selected.GetComponent <Renderer>();
                    }
                }
            }
        }

        if (selected && isSelected)
        {
            rend.material.shader = shader2;
            MoveBody MoveBody = selected.GetComponent <MoveBody>();
            MoveBody.enabled = true;
        }
        else if (selected)
        {
            rend.material.shader = shader1;
            MoveBody MoveBody = selected.GetComponent <MoveBody>();
            MoveBody.enabled = false;
            isSelected       = false;
        }
        else
        {
            rend.material.shader = shader1;
            selected             = null;
            rend = null;
        }
    }
Esempio n. 3
0
 void Start()
 {
     _moveBody = GetComponent <MoveBody>();
 }