GetTypeForControl() private method

private GetTypeForControl ( int controlID ) : EventType
controlID int
return EventType
Ejemplo n.º 1
0
 static public int GetTypeForControl(IntPtr l)
 {
     try {
         UnityEngine.Event self = (UnityEngine.Event)checkSelf(l);
         System.Int32      a1;
         checkType(l, 2, out a1);
         var ret = self.GetTypeForControl(a1);
         pushEnum(l, (int)ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 2
0
 static public int GetTypeForControl(IntPtr l)
 {
     try{
         UnityEngine.Event self = (UnityEngine.Event)checkSelf(l);
         System.Int32      a1;
         checkType(l, 2, out a1);
         UnityEngine.EventType ret = self.GetTypeForControl(a1);
         pushEnum(l, (int)ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static int GetTypeForControl(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Event obj = (UnityEngine.Event)ToLua.CheckObject(L, 1, typeof(UnityEngine.Event));
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         UnityEngine.EventType o = obj.GetTypeForControl(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 4
0
    void MouseScroll(Rect position)
    {
        UnityEngine.Event current = UnityEngine.Event.current;
        int controlID             = GUIUtility.GetControlID(sliderHash, FocusType.Passive);

        switch (current.GetTypeForControl(controlID))
        {
        case EventType.ScrollWheel:
            if (position.Contains(current.mousePosition))
            {
                m_orthoGoal          += current.delta.y * ((SkeletonDataAsset)target).scale * 10;
                GUIUtility.hotControl = controlID;
                current.Use();
            }
            break;
        }
    }
Ejemplo n.º 5
0
        public static bool OnMouseMoveDrag(this UnityEngine.Event source)
        {
            var id   = GUIUtility.GetControlID(FocusType.Passive);
            var type = source.GetTypeForControl(id);

            if (type == EventType.MouseDrag)
            {
                GUIUtility.hotControl = id;
                source.Use();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        public static bool OnMouseDown(this UnityEngine.Event source, Rect rect, int index)
        {
            var id   = GUIUtility.GetControlID(FocusType.Passive);
            var type = source.GetTypeForControl(id);

            if (type == EventType.MouseDown && source.button == index && rect.Contains(source.mousePosition))
            {
                GUIUtility.hotControl = id;
                source.Use();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        public static bool OnMouseUp(this UnityEngine.Event source, int index)
        {
            var id   = GUIUtility.GetControlID(FocusType.Passive);
            var type = source.GetTypeForControl(id);

            if (type == EventType.MouseUp && source.button == index)
            {
                GUIUtility.hotControl = 0;
                source.Use();

                return(true);
            }
            else
            {
                return(false);
            }
        }
        void MouseScroll(Rect position)
        {
            UnityEngine.Event current = UnityEngine.Event.current;
            int controlID             = GUIUtility.GetControlID(SliderHash, FocusType.Passive);

            switch (current.GetTypeForControl(controlID))
            {
            case EventType.ScrollWheel:
                if (position.Contains(current.mousePosition))
                {
                    m_orthoGoal          += current.delta.y * 0.06f;
                    m_orthoGoal           = Mathf.Max(0.01f, m_orthoGoal);
                    GUIUtility.hotControl = controlID;
                    current.Use();
                }
                break;
            }
        }
        public static Vector2 Drag2D(Vector2 scrollPosition, Rect position)
        {
            int controlID = GUIUtility.GetControlID("Slider".GetHashCode(), FocusType.Passive);

            UnityEngine.Event current = UnityEngine.Event.current;
            switch (current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:
                if (position.Contains(current.mousePosition) && position.width > 50f)
                {
                    GUIUtility.hotControl = controlID;
                    current.Use();
                    // 让鼠标可以拖动到屏幕外后,从另一边出来
                    EditorGUIUtility.SetWantsMouseJumping(1);
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == controlID)
                {
                    GUIUtility.hotControl = 0;
                }
                EditorGUIUtility.SetWantsMouseJumping(0);
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    // 按住 Shift 键后,可以加快旋转
                    scrollPosition  -= current.delta * (float)((!current.shift) ? 1 : 3) / Mathf.Min(position.width, position.height) * 140f;
                    scrollPosition.y = Mathf.Clamp(scrollPosition.y, -90f, 90f);
                    current.Use();
                    GUI.changed = true;
                }
                break;
            }
            return(scrollPosition);
        }
Ejemplo n.º 10
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            UnityEngine.Event e = UnityEngine.Event.current;
            controlId = EditorGUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
            switch (e.GetTypeForControl(controlId))
            {
            default:

                position = EditorGUI.IndentedRect(position);
                Rect pos2 = position;
                pos2.width -= 32;
                Rect pos3 = position;
                pos3.x    += pos2.width;
                pos3.width = 15;
                Rect pos4 = position;
                pos4.x    += pos2.width + pos3.width;
                pos4.width = 15;

                var    typeName = property.FindPropertyRelative("m_Name");
                string name     = (typeName != null && !string.IsNullOrEmpty(typeName.stringValue) ? typeName.stringValue : "None");

                GUI.Label(pos2, name);

                if (GUI.Button(pos3, "s"))
                {
                    TypePickerAttribute attr = attribute as TypePickerAttribute;
                    if (attr != null)
                    {
                        TypePicker.Show(controlId, attr.baseType);
                    }
                }

                if (GUI.Button(pos4, "x"))
                {
                    var assemblyQualifiedName = property.FindPropertyRelative("m_AssemblyQualifiedName");
                    var nameProperty          = property.FindPropertyRelative("m_Name");
                    var assemblyName          = property.FindPropertyRelative("m_AssemblyName");

                    assemblyQualifiedName.stringValue = "";
                    nameProperty.stringValue          = "";
                    assemblyName.stringValue          = "";

                    property.serializedObject.ApplyModifiedProperties();
                }

                if (e.commandName == "TypePickerSelectionChanged" || e.commandName == "TypePickerClosed")
                {
                    if (TypePicker.GetControlId() == controlId)
                    {
                        GUI.changed = true;
                        var selection = TypePicker.GetSelection();
                        if (selection.Length > 0 && selection[0] != null)
                        {
                            var assemblyQualifiedName = property.FindPropertyRelative("m_AssemblyQualifiedName");
                            var nameProperty          = property.FindPropertyRelative("m_Name");
                            var assemblyName          = property.FindPropertyRelative("m_AssemblyName");

                            assemblyQualifiedName.stringValue = selection[0].AssemblyQualifiedName;
                            nameProperty.stringValue          = selection[0].Name;
                            assemblyName.stringValue          = selection[0].FullName;

                            property.serializedObject.ApplyModifiedProperties();
                        }
                    }
                }
                break;
            }
        }
Ejemplo n.º 11
0
		public void SplitGUI(Event evt)
		{
			if (this.splitState == null)
			{
				this.SetupSplitter();
			}
			SplitView splitView = base.parent as SplitView;
			if (splitView)
			{
				Event @event = new Event(evt);
				@event.mousePosition += new Vector2(base.position.x, base.position.y);
				splitView.SplitGUI(@event);
				if (@event.type == EventType.Used)
				{
					evt.Use();
				}
			}
			float num = (!this.vertical) ? evt.mousePosition.x : evt.mousePosition.y;
			int num2 = GUIUtility.GetControlID(546739, FocusType.Passive);
			this.controlID = num2;
			switch (evt.GetTypeForControl(num2))
			{
			case EventType.MouseDown:
				if (base.children.Length != 1)
				{
					int num3 = (!this.vertical) ? ((int)base.children[0].position.x) : ((int)base.children[0].position.y);
					for (int i = 0; i < base.children.Length - 1; i++)
					{
						if (i >= this.splitState.realSizes.Length)
						{
							DockArea dockArea = GUIView.current as DockArea;
							string text = "Non-dock area " + GUIView.current.GetType();
							if (dockArea && dockArea.m_Selected < dockArea.m_Panes.Count && dockArea.m_Panes[dockArea.m_Selected])
							{
								text = dockArea.m_Panes[dockArea.m_Selected].GetType().ToString();
							}
							if (Unsupported.IsDeveloperBuild())
							{
								Debug.LogError(string.Concat(new object[]
								{
									"Real sizes out of bounds for: ",
									text,
									" index: ",
									i,
									" RealSizes: ",
									this.splitState.realSizes.Length
								}));
							}
							this.SetupSplitter();
						}
						if (((!this.vertical) ? new Rect((float)(num3 + this.splitState.realSizes[i] - this.splitState.splitSize / 2), base.children[0].position.y, (float)this.splitState.splitSize, base.children[0].position.height) : new Rect(base.children[0].position.x, (float)(num3 + this.splitState.realSizes[i] - this.splitState.splitSize / 2), base.children[0].position.width, (float)this.splitState.splitSize)).Contains(evt.mousePosition))
						{
							this.splitState.splitterInitialOffset = (int)num;
							this.splitState.currentActiveSplitter = i;
							GUIUtility.hotControl = num2;
							evt.Use();
							break;
						}
						num3 += this.splitState.realSizes[i];
					}
				}
				break;
			case EventType.MouseUp:
				if (GUIUtility.hotControl == num2)
				{
					GUIUtility.hotControl = 0;
				}
				break;
			case EventType.MouseDrag:
				if (base.children.Length > 1 && GUIUtility.hotControl == num2 && this.splitState.currentActiveSplitter >= 0)
				{
					int num4 = (int)num - this.splitState.splitterInitialOffset;
					if (num4 != 0)
					{
						this.splitState.splitterInitialOffset = (int)num;
						this.splitState.DoSplitter(this.splitState.currentActiveSplitter, this.splitState.currentActiveSplitter + 1, num4);
					}
					this.SetupRectsFromSplitter();
					evt.Use();
				}
				break;
			}
		}
Ejemplo n.º 12
0
 public EventType GetTypeForControl(int id)
 {
     return(m_Event.GetTypeForControl(id));
 }
Ejemplo n.º 13
0
 public void SplitGUI(Event evt)
 {
   if (this.splitState == null)
     this.SetupSplitter();
   SplitView parent = this.parent as SplitView;
   if ((bool) ((Object) parent))
   {
     Event evt1 = new Event(evt);
     evt1.mousePosition += new Vector2(this.position.x, this.position.y);
     parent.SplitGUI(evt1);
     if (evt1.type == EventType.Used)
       evt.Use();
   }
   float num1 = !this.vertical ? evt.mousePosition.x : evt.mousePosition.y;
   int controlId = GUIUtility.GetControlID(546739, FocusType.Passive);
   this.controlID = controlId;
   switch (evt.GetTypeForControl(controlId))
   {
     case EventType.MouseDown:
       if (this.children.Length == 1)
         break;
       int num2 = !this.vertical ? (int) this.children[0].position.x : (int) this.children[0].position.y;
       for (int index = 0; index < this.children.Length - 1; ++index)
       {
         if (index >= this.splitState.realSizes.Length)
         {
           DockArea current = GUIView.current as DockArea;
           string str = "Non-dock area " + (object) GUIView.current.GetType();
           if ((bool) ((Object) current) && current.m_Selected < current.m_Panes.Count && (bool) ((Object) current.m_Panes[current.m_Selected]))
             str = current.m_Panes[current.m_Selected].GetType().ToString();
           if (Unsupported.IsDeveloperBuild())
             Debug.LogError((object) ("Real sizes out of bounds for: " + str + " index: " + (object) index + " RealSizes: " + (object) this.splitState.realSizes.Length));
           this.SetupSplitter();
         }
         if ((!this.vertical ? new Rect((float) (num2 + this.splitState.realSizes[index] - this.splitState.splitSize / 2), this.children[0].position.y, (float) this.splitState.splitSize, this.children[0].position.height) : new Rect(this.children[0].position.x, (float) (num2 + this.splitState.realSizes[index] - this.splitState.splitSize / 2), this.children[0].position.width, (float) this.splitState.splitSize)).Contains(evt.mousePosition))
         {
           this.splitState.splitterInitialOffset = (int) num1;
           this.splitState.currentActiveSplitter = index;
           GUIUtility.hotControl = controlId;
           evt.Use();
           break;
         }
         num2 += this.splitState.realSizes[index];
       }
       break;
     case EventType.MouseUp:
       if (GUIUtility.hotControl != controlId)
         break;
       GUIUtility.hotControl = 0;
       break;
     case EventType.MouseDrag:
       if (this.children.Length <= 1 || GUIUtility.hotControl != controlId || this.splitState.currentActiveSplitter < 0)
         break;
       int diff = (int) num1 - this.splitState.splitterInitialOffset;
       if (diff != 0)
       {
         this.splitState.splitterInitialOffset = (int) num1;
         this.splitState.DoSplitter(this.splitState.currentActiveSplitter, this.splitState.currentActiveSplitter + 1, diff);
       }
       this.SetupRectsFromSplitter();
       evt.Use();
       break;
   }
 }
Ejemplo n.º 14
0
 public void SplitGUI(Event evt)
 {
     if (this.splitState == null)
     {
         this.SetupSplitter();
     }
     SplitView parent = base.parent as SplitView;
     if (parent != null)
     {
         Event event2 = new Event(evt);
         event2.mousePosition += new Vector2(base.position.x, base.position.y);
         parent.SplitGUI(event2);
         if (event2.type == EventType.Used)
         {
             evt.Use();
         }
     }
     float num = !this.vertical ? evt.mousePosition.x : evt.mousePosition.y;
     int controlID = GUIUtility.GetControlID(0x857b3, FocusType.Passive);
     this.controlID = controlID;
     EventType typeForControl = evt.GetTypeForControl(controlID);
     if (typeForControl == EventType.MouseDown)
     {
         if (base.children.Length != 1)
         {
             int num3 = !this.vertical ? ((int) base.children[0].position.x) : ((int) base.children[0].position.y);
             for (int i = 0; i < (base.children.Length - 1); i++)
             {
                 if (i >= this.splitState.realSizes.Length)
                 {
                     DockArea current = GUIView.current as DockArea;
                     string str = "Non-dock area " + GUIView.current.GetType();
                     if (((current != null) && (current.m_Selected < current.m_Panes.Count)) && (current.m_Panes[current.m_Selected] != null))
                     {
                         str = current.m_Panes[current.m_Selected].GetType().ToString();
                     }
                     if (Unsupported.IsDeveloperBuild())
                     {
                         Debug.LogError(string.Concat(new object[] { "Real sizes out of bounds for: ", str, " index: ", i, " RealSizes: ", this.splitState.realSizes.Length }));
                     }
                     this.SetupSplitter();
                 }
                 Rect rect5 = !this.vertical ? new Rect((float) ((num3 + this.splitState.realSizes[i]) - (this.splitState.splitSize / 2)), base.children[0].position.y, (float) this.splitState.splitSize, base.children[0].position.height) : new Rect(base.children[0].position.x, (float) ((num3 + this.splitState.realSizes[i]) - (this.splitState.splitSize / 2)), base.children[0].position.width, (float) this.splitState.splitSize);
                 if (rect5.Contains(evt.mousePosition))
                 {
                     this.splitState.splitterInitialOffset = (int) num;
                     this.splitState.currentActiveSplitter = i;
                     GUIUtility.hotControl = controlID;
                     evt.Use();
                     break;
                 }
                 num3 += this.splitState.realSizes[i];
             }
         }
     }
     else if (typeForControl == EventType.MouseDrag)
     {
         if (((base.children.Length > 1) && (GUIUtility.hotControl == controlID)) && (this.splitState.currentActiveSplitter >= 0))
         {
             int diff = ((int) num) - this.splitState.splitterInitialOffset;
             if (diff != 0)
             {
                 this.splitState.splitterInitialOffset = (int) num;
                 this.splitState.DoSplitter(this.splitState.currentActiveSplitter, this.splitState.currentActiveSplitter + 1, diff);
             }
             this.SetupRectsFromSplitter();
             evt.Use();
         }
     }
     else if ((typeForControl == EventType.MouseUp) && (GUIUtility.hotControl == controlID))
     {
         GUIUtility.hotControl = 0;
     }
 }