Advertisement
CassataGames

Untitled

Sep 10th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class EditorControls : MonoBehaviour {
  5.    
  6.     bool ShiftHeld;
  7.  
  8.     public EditorGlobals GlobalAccess;
  9.     void Start()
  10.     {        
  11.         // Required to have GlobalAccess
  12.         GlobalAccess = GameObject.Find("EditorGlobals").GetComponent<EditorGlobals>();
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update ()
  17.     {
  18.         ShiftHeld = Input.GetKey(KeyCode.LeftShift);
  19.  
  20.         if (!GlobalAccess.OverToolbar)
  21.             MouseControlGrid();
  22.  
  23.     }
  24.  
  25.     // This function is only called when the mouse is on the editor and has permission to make edits.
  26.     void MouseControlGrid()
  27.     {
  28.         // Mouse controls while shift is not being held.
  29.         if (!ShiftHeld)
  30.         {
  31.             if (Input.GetMouseButtonDown(0))
  32.             {
  33.                 Instantiate(GlobalAccess.Components.RequestGameObject(GlobalAccess.ComponentSelected));
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement