Ejemplo n.º 1
0
		static private bool CheckChild(SerializedProperty property)
		{
			var types = new [] {
				SerializedPropertyType.String,
				SerializedPropertyType.Color,
				SerializedPropertyType.Vector2,
				SerializedPropertyType.Vector3,
				SerializedPropertyType.Quaternion,
				SerializedPropertyType.ObjectReference,
			};
			return !types.Contains(property.propertyType);
		}
Ejemplo n.º 2
0
	public bool DrawPreview(UnityEngine.Rect position) {
		UnityEngine.Texture texture = GetTexture();
		if(texture != null) UnityEngine.GUI.DrawTextureWithTexCoords(position, texture, GetPreviewFace());
		return UnityEngine.Event.current.type == UnityEngine.EventType.MouseDown && position.Contains(UnityEngine.Event.current.mousePosition);
	}
Ejemplo n.º 3
0
        private static bool ButtonBase(UnityEngine.Rect bounds, GUIContent content, bool on, GUIStyle style, bool forceOnTop)
        {
            Contract.ArgumentNotNull("style", style);

            int controlID = GUIUtility.GetControlID(content, FocusType.Passive);
            bool isMouseOver = bounds.Contains(Event.current.mousePosition);
            int depth = (1000 - GUI.depth) * 1000 + (forceOnTop ? 10000 : controlID);
            if (isMouseOver && depth > highestDepthID)
            {
                highestDepthID = depth;
            }
    
            bool isTopmostMouseOver = (highestDepthID == depth);
    
    #if (UNITY_IPHONE || UNITY_ANDROID)  && !UNITY_EDITOR
            bool paintMouseOver = isTopmostMouseOver && (Input.touchCount > 0);
    #else
            bool paintMouseOver = isTopmostMouseOver;
    
    #endif
    
            if ( Event.current.type == EventType.Layout && lastEventType != EventType.Layout )
            {
                highestDepthID = 0;
                frame++;
            }
    
            lastEventType = Event.current.type;
            if (Event.current.type == EventType.Repaint)
            {
                bool isDown = (GUIUtility.hotControl == controlID);
                style.Draw(bounds, content, paintMouseOver, isDown, on, false);
            }

    #if (UNITY_IPHONE || UNITY_ANDROID)  && !UNITY_EDITOR
            if ( Input.touchCount > 0 )
            {
                Touch touch = Input.GetTouch(0);
                if ( touch.phase == TouchPhase.Began )
                {
                    touchBeganPosition = touch.position;
                    wasDragging = true;
                }
                else if ( touch.phase == TouchPhase.Ended
                        && ((Mathf.Abs(touch.position.x - touchBeganPosition.x) > 15)
                            || (Mathf.Abs(touch.position.y - touchBeganPosition.y) > 15)))
                {
                    wasDragging = true;
                }
                else
                {
                    wasDragging = false;
                }
            }
            else if ( Event.current.type == EventType.Repaint )
            {
                wasDragging = false;
            }
    #endif
    
            // Workaround:
            // ignore duplicate mouseUp events. These can occur when running
            // unity editor with unity remote on iOS ... (anybody knows WHY?)
            if ( frame <= (1+lastEventFrame) )
            {
                return false;
            }

            if (isMouseOver)
            {
                switch (Event.current.GetTypeForControl(controlID))
                {
                    case EventType.mouseDown:
                    {
                        //DebugLog.Info("UnityButton: Mouse DOWN over controlID={0} isTopmostMouseOver={1} depth={2} highest depth={3} wasDragging={4} content={5}",
                        //controlID, isTopmostMouseOver, depth, highestDepthID, wasDragging, content.text);
                        if (isTopmostMouseOver && !wasDragging)
                        {
                            GUIUtility.hotControl = controlID;
                            Event.current.Use();
                        }
                        break;
                    }
    
                    case EventType.mouseUp:
                    {
                        //DebugLog.Info("UnityButton: Mouse UP over controlID={0} isTopmostMouseOver={1} depth={2} highest depth={3} wasDragging={4} content={5}",
                        //controlID, isTopmostMouseOver, depth, highestDepthID, wasDragging, content.text);
                        if (isTopmostMouseOver && !wasDragging)
                        {
                            GUIUtility.hotControl = 0;
                            lastEventFrame = frame;
                            Event.current.Use();
                            return true;
                        }
                        break;
                    }
                }
            }

            return false;
        }