예제 #1
0
    void FixedUpdate()
    {
        RaycastHit hit;

        Ray ray = cam.ScreenPointToRay(gameObject.transform.position);

        ray.direction = gameObject.transform.forward;


        if (Physics.Raycast(ray, out hit))
        {
            /*
             * if (last != hit.collider.gameObject && last != null)
             * {
             *  Renderer rend = hit.collider.gameObject.GetComponent<Renderer>();
             *  current = hit.collider.gameObject;
             *  Renderer rend2 = last.GetComponent<Renderer>();
             *
             *  if (rend2 != null && last != null)
             *  {
             *      rend2.material.color = Original;
             *  }
             *  if (rend != null)
             *  {
             *      Original = rend.material.color;
             *      rend.material.color = red;
             *  }
             * }
             */


            if (last != hit.collider.gameObject && last != null)
            {
                Debug.Log("hit");
                Renderer rend = hit.collider.gameObject.GetComponent <Renderer>();
                current = hit.collider.gameObject;
                placeable p = last.GetComponent <placeable>();

                if (p == null)
                {
                    p = last.GetComponentInParent <placeable>();
                }
                if (p != null)
                {
                    p.ResetColor();
                }
                rend.material.color = red;
            }
            if (Input.GetMouseButtonDown(0))
            {
                MouseButton();
            }
            last = hit.collider.gameObject;
        }
    }
예제 #2
0
 public override void EndCommand()
 {
     if (current != null)
     {
         placeable rend = current.GetComponent <placeable>();
         if (rend != null)
         {
             rend.ResetColor();
         }
     }
 }