示例#1
0
 // Give a value to gizmo state
 void affect_state(GameObject current)
 {
     switch (current.tag)
     {
     case "ArrowX":
         state = gizmo_state.arrowX;
         break;
     case "ArrowY":
         state = gizmo_state.arrowY;
         break;
     case "ArrowZ":
         state = gizmo_state.arrowZ;
         break;
     case "WheelX":
         state = gizmo_state.wheelX;
         break;
     case "WheelY":
         state = gizmo_state.wheelY;
         break;
     case "WheelZ":
         state = gizmo_state.wheelZ;
         break;
     default:
         state = gizmo_state.defaut;
         break;
     }
 }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        // if button is up, the status of gizmo is "defaut" and position is the position of object
        if (Input.GetMouseButtonUp(0))
        {
            if (selectObject != null)
            {
                Gizmo.transform.position = selectObject.transform.position;
                Gizmo.transform.rotation = selectObject.transform.rotation;
            }
            state = gizmo_state.defaut;
        }

        if (Input.GetKeyDown(KeyCode.LeftControl))
            ctrl = true;

        if (Input.GetKeyUp(KeyCode.LeftControl))
            ctrl = false;

        if (Input.GetKeyDown(KeyCode.LeftShift))
            shift = true;

        if (Input.GetKeyUp(KeyCode.LeftShift))
            shift = false;

        // move object and gizmo
        if (state >= gizmo_state.arrowX && state <= gizmo_state.arrowZ)
            change_object_position();
        else if (state >= gizmo_state.wheelX && state <= gizmo_state.wheelZ)
            change_object_rotation();
    }
示例#3
0
 void Start()
 {
     Gizmo.SetActive(false);
     state = gizmo_state.defaut;
     m_interface = Interface.Instance;
     selectObject = null;
     current = null;
     ctrl = false;
     b_arrow = false;
     b_wheel = false;
     layermask = 1 << LayerMask.NameToLayer("Snap");
     layermask = ~layermask;
 }