Exemplo n.º 1
0
 internal static void Snap(SnapEdge edge, List <SnapEdge> otherEdges, ref float maxDist, ref float snapVal, List <KeyValuePair <SnapEdge, SnapEdge> > activeEdges)
 {
     using (List <SnapEdge> .Enumerator enumerator = otherEdges.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             SnapEdge current = enumerator.Current;
             if (SnapEdge.ShouldEdgesSnap(edge, current))
             {
                 float num = Mathf.Abs(current.pos - edge.pos);
                 if ((double)num < (double)maxDist)
                 {
                     maxDist = num;
                     snapVal = current.pos - edge.pos;
                     activeEdges.Clear();
                     activeEdges.Add(new KeyValuePair <SnapEdge, SnapEdge>(edge, current));
                 }
                 else if ((double)num == (double)maxDist)
                 {
                     activeEdges.Add(new KeyValuePair <SnapEdge, SnapEdge>(edge, current));
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
		internal SnapEdge(UnityEngine.Object win, SnapEdge.EdgeDir _d, float _p, float _s, float _e)
		{
			this.dir = _d;
			this.m_Object = win;
			this.pos = _p;
			this.start = _s;
			this.end = _e;
		}
Exemplo n.º 3
0
        private void DragTitleBar(Rect titleBarRect)
        {
            int   controlId = GUIUtility.GetControlID(FocusType.Passive);
            Event current1  = Event.current;

            switch (current1.GetTypeForControl(controlId))
            {
            case EventType.MouseDown:
                if (!titleBarRect.Contains(current1.mousePosition) || GUIUtility.hotControl != 0 || current1.button != 0)
                {
                    break;
                }
                GUIUtility.hotControl = controlId;
                Event.current.Use();
                ContainerWindow.s_LastDragMousePos = GUIUtility.GUIToScreenPoint(current1.mousePosition);
                using (IEnumerator <SnapEdge> enumerator = this.edges.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        SnapEdge current2 = enumerator.Current;
                        current2.startDragPos   = current2.pos;
                        current2.startDragStart = current2.start;
                    }
                    break;
                }

            case EventType.MouseUp:
                if (GUIUtility.hotControl != controlId)
                {
                    break;
                }
                GUIUtility.hotControl = 0;
                Event.current.Use();
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl != controlId)
                {
                    break;
                }
                Vector2 screenPoint = GUIUtility.GUIToScreenPoint(current1.mousePosition);
                Vector2 offset      = screenPoint - ContainerWindow.s_LastDragMousePos;
                ContainerWindow.s_LastDragMousePos = screenPoint;
                GUI.changed = true;
                using (IEnumerator <SnapEdge> enumerator = this.edges.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        enumerator.Current.ApplyOffset(offset, true);
                    }
                    break;
                }

            case EventType.Repaint:
                EditorGUIUtility.AddCursorRect(titleBarRect, MouseCursor.Arrow);
                break;
            }
        }
Exemplo n.º 4
0
 private static bool EdgeInside(SnapEdge edge, List <SnapEdge> frustum)
 {
     foreach (SnapEdge current in frustum)
     {
         if (!SnapEdge.ShouldEdgesSnap(edge, current))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 5
0
 private static bool EdgeInside(SnapEdge edge, List<SnapEdge> frustum)
 {
     foreach (SnapEdge edge2 in frustum)
     {
         if (!ShouldEdgesSnap(edge, edge2))
         {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 6
0
 private static bool ShouldEdgesSnap(SnapEdge a, SnapEdge b)
 {
     if ((a.dir == SnapEdge.EdgeDir.CenterX || a.dir == SnapEdge.EdgeDir.CenterY) && a.dir == b.dir)
     {
         return(true);
     }
     if (a.dir == SnapEdge.OppositeEdge(b.dir))
     {
         return(((double)a.start > (double)b.end ? 1 : ((double)a.end < (double)b.start ? 1 : 0)) == 0);
     }
     return(false);
 }
Exemplo n.º 7
0
 private static bool EdgeInside(SnapEdge edge, List<SnapEdge> frustum)
 {
   using (List<SnapEdge>.Enumerator enumerator = frustum.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       SnapEdge current = enumerator.Current;
       if (!SnapEdge.ShouldEdgesSnap(edge, current))
         return false;
     }
   }
   return true;
 }
Exemplo n.º 8
0
 private static bool EdgeInside(SnapEdge edge, List <SnapEdge> frustum)
 {
     using (List <SnapEdge> .Enumerator enumerator = frustum.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             SnapEdge current = enumerator.Current;
             if (!SnapEdge.ShouldEdgesSnap(edge, current))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 9
0
		internal static SnapEdge.EdgeDir OppositeEdge(SnapEdge.EdgeDir dir)
		{
			switch (dir)
			{
			case SnapEdge.EdgeDir.Left:
				return SnapEdge.EdgeDir.Right;
			case SnapEdge.EdgeDir.Right:
				return SnapEdge.EdgeDir.Left;
			case SnapEdge.EdgeDir.CenterX:
				return SnapEdge.EdgeDir.CenterX;
			case SnapEdge.EdgeDir.Up:
				return SnapEdge.EdgeDir.Down;
			case SnapEdge.EdgeDir.Down:
				return SnapEdge.EdgeDir.Up;
			}
			return SnapEdge.EdgeDir.CenterY;
		}
Exemplo n.º 10
0
        private void SetupWindowEdges()
        {
            Rect position = this.position;

            if (this.m_Left == null)
            {
                this.m_Left   = new SnapEdge(this, SnapEdge.EdgeDir.Left, position.xMin, position.yMin, position.yMax);
                this.m_Right  = new SnapEdge(this, SnapEdge.EdgeDir.Right, position.xMax, position.yMin, position.yMax);
                this.m_Top    = new SnapEdge(this, SnapEdge.EdgeDir.Up, position.yMin, position.xMin, position.xMax);
                this.m_Bottom = new SnapEdge(this, SnapEdge.EdgeDir.Down, position.yMax, position.xMin, position.xMax);
                for (int i = 0; i < 9; i++)
                {
                    this.edges[i] = new List <SnapEdge>();
                }
                this.edges[0].Add(this.m_Top);
                this.edges[0].Add(this.m_Left);
                this.edges[1].Add(this.m_Top);
                this.edges[2].Add(this.m_Top);
                this.edges[2].Add(this.m_Right);
                this.edges[3].Add(this.m_Left);
                this.edges[4].Add(this.m_Left);
                this.edges[4].Add(this.m_Right);
                this.edges[4].Add(this.m_Top);
                this.edges[4].Add(this.m_Bottom);
                this.edges[5].Add(this.m_Right);
                this.edges[6].Add(this.m_Bottom);
                this.edges[6].Add(this.m_Left);
                this.edges[7].Add(this.m_Bottom);
                this.edges[8].Add(this.m_Bottom);
                this.edges[8].Add(this.m_Right);
            }
            this.m_Left.pos     = position.xMin;
            this.m_Left.start   = position.yMin;
            this.m_Left.end     = position.yMax;
            this.m_Right.pos    = position.xMax;
            this.m_Right.start  = position.yMin;
            this.m_Right.end    = position.yMax;
            this.m_Top.pos      = position.yMin;
            this.m_Top.start    = position.xMin;
            this.m_Top.end      = position.xMax;
            this.m_Bottom.pos   = position.yMax;
            this.m_Bottom.start = position.xMin;
            this.m_Bottom.end   = position.xMax;
        }
Exemplo n.º 11
0
 internal static void Snap(SnapEdge edge, List <SnapEdge> otherEdges, ref float maxDist, ref float snapVal, List <KeyValuePair <SnapEdge, SnapEdge> > activeEdges)
 {
     foreach (SnapEdge current in otherEdges)
     {
         if (SnapEdge.ShouldEdgesSnap(edge, current))
         {
             float num = Mathf.Abs(current.pos - edge.pos);
             if (num < maxDist)
             {
                 maxDist = num;
                 snapVal = current.pos - edge.pos;
                 activeEdges.Clear();
                 activeEdges.Add(new KeyValuePair <SnapEdge, SnapEdge>(edge, current));
             }
             else if (num == maxDist)
             {
                 activeEdges.Add(new KeyValuePair <SnapEdge, SnapEdge>(edge, current));
             }
         }
     }
 }
Exemplo n.º 12
0
        internal static Vector2 Snap(List <SnapEdge> sourceEdges, List <SnapEdge> edgesToSnapAgainst, List <KeyValuePair <SnapEdge, SnapEdge> >[] activeEdges)
        {
            Vector2 zero = Vector2.zero;
            float   num  = 10f;

            activeEdges[0].Clear();
            activeEdges[1].Clear();
            float[] array = new float[]
            {
                num,
                num
            };
            float[] array2 = new float[2];
            foreach (SnapEdge current in sourceEdges)
            {
                int num2 = current.EdgeCoordinateIndex();
                SnapEdge.Snap(current, edgesToSnapAgainst, ref array[num2], ref array2[num2], activeEdges[num2]);
            }
            zero.x = array2[0];
            zero.y = array2[1];
            return(zero);
        }
Exemplo n.º 13
0
        private void SetupWindowEdges()
        {
            Rect position = this.position;

            if (this.m_Left == null)
            {
                this.m_Left   = new SnapEdge(this, SnapEdge.EdgeDir.Left, position.xMin, position.yMin, position.yMax);
                this.m_Right  = new SnapEdge(this, SnapEdge.EdgeDir.Right, position.xMax, position.yMin, position.yMax);
                this.m_Top    = new SnapEdge(this, SnapEdge.EdgeDir.Up, position.yMin, position.xMin, position.xMax);
                this.m_Bottom = new SnapEdge(this, SnapEdge.EdgeDir.Down, position.yMax, position.xMin, position.xMax);
            }
            this.m_Left.pos     = position.xMin;
            this.m_Left.start   = position.yMin;
            this.m_Left.end     = position.yMax;
            this.m_Right.pos    = position.xMax;
            this.m_Right.start  = position.yMin;
            this.m_Right.end    = position.yMax;
            this.m_Top.pos      = position.yMin;
            this.m_Top.start    = position.xMin;
            this.m_Top.end      = position.xMax;
            this.m_Bottom.pos   = position.yMax;
            this.m_Bottom.start = position.xMin;
            this.m_Bottom.end   = position.xMax;
        }
Exemplo n.º 14
0
        internal static Vector2 Snap(List <SnapEdge> sourceEdges, List <SnapEdge> edgesToSnapAgainst, List <KeyValuePair <SnapEdge, SnapEdge> >[] activeEdges)
        {
            Vector2 zero = Vector2.zero;
            float   num  = 10f;

            activeEdges[0].Clear();
            activeEdges[1].Clear();
            float[] numArray1 = new float[2] {
                num, num
            };
            float[] numArray2 = new float[2];
            using (List <SnapEdge> .Enumerator enumerator = sourceEdges.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SnapEdge current = enumerator.Current;
                    int      index   = current.EdgeCoordinateIndex();
                    SnapEdge.Snap(current, edgesToSnapAgainst, ref numArray1[index], ref numArray2[index], activeEdges[index]);
                }
            }
            zero.x = numArray2[0];
            zero.y = numArray2[1];
            return(zero);
        }
Exemplo n.º 15
0
 internal static void Snap(SnapEdge edge, List<SnapEdge> otherEdges, ref float maxDist, ref float snapVal, List<KeyValuePair<SnapEdge, SnapEdge>> activeEdges)
 {
   using (List<SnapEdge>.Enumerator enumerator = otherEdges.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       SnapEdge current = enumerator.Current;
       if (SnapEdge.ShouldEdgesSnap(edge, current))
       {
         float num = Mathf.Abs(current.pos - edge.pos);
         if ((double) num < (double) maxDist)
         {
           maxDist = num;
           snapVal = current.pos - edge.pos;
           activeEdges.Clear();
           activeEdges.Add(new KeyValuePair<SnapEdge, SnapEdge>(edge, current));
         }
         else if ((double) num == (double) maxDist)
           activeEdges.Add(new KeyValuePair<SnapEdge, SnapEdge>(edge, current));
       }
     }
   }
 }
Exemplo n.º 16
0
        private void DragTitleBar(Rect titleBarRect)
        {
            int   controlID = GUIUtility.GetControlID(FocusType.Passive);
            Event current   = Event.current;

            switch (current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:
                if ((titleBarRect.Contains(current.mousePosition) && (GUIUtility.hotControl == 0)) && (current.button == 0))
                {
                    GUIUtility.hotControl = controlID;
                    Event.current.Use();
                    s_LastDragMousePos = GUIUtility.GUIToScreenPoint(current.mousePosition);
                    IEnumerator <SnapEdge> enumerator = this.edges.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            SnapEdge edge = enumerator.Current;
                            edge.startDragPos   = edge.pos;
                            edge.startDragStart = edge.start;
                        }
                    }
                    finally
                    {
                        if (enumerator == null)
                        {
                        }
                        enumerator.Dispose();
                    }
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == controlID)
                {
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    Vector2 vector = GUIUtility.GUIToScreenPoint(current.mousePosition);
                    Vector2 offset = vector - s_LastDragMousePos;
                    s_LastDragMousePos = vector;
                    GUI.changed        = true;
                    IEnumerator <SnapEdge> enumerator2 = this.edges.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            enumerator2.Current.ApplyOffset(offset, true);
                        }
                    }
                    finally
                    {
                        if (enumerator2 == null)
                        {
                        }
                        enumerator2.Dispose();
                    }
                }
                break;

            case EventType.Repaint:
                EditorGUIUtility.AddCursorRect(titleBarRect, MouseCursor.Arrow);
                break;
            }
        }
Exemplo n.º 17
0
 private static bool ShouldEdgesSnap(SnapEdge a, SnapEdge b)
 {
     return ((((a.dir == EdgeDir.CenterX) || (a.dir == EdgeDir.CenterY)) && (a.dir == b.dir)) || ((a.dir == OppositeEdge(b.dir)) && ((a.start <= b.end) && (a.end >= b.start))));
 }
Exemplo n.º 18
0
 private static bool ShouldEdgesSnap(SnapEdge a, SnapEdge b)
 {
   if ((a.dir == SnapEdge.EdgeDir.CenterX || a.dir == SnapEdge.EdgeDir.CenterY) && a.dir == b.dir)
     return true;
   if (a.dir == SnapEdge.OppositeEdge(b.dir))
     return ((double) a.start > (double) b.end ? 1 : ((double) a.end < (double) b.start ? 1 : 0)) == 0;
   return false;
 }
Exemplo n.º 19
0
 internal static void Snap(SnapEdge edge, List<SnapEdge> otherEdges, ref float maxDist, ref float snapVal, List<KeyValuePair<SnapEdge, SnapEdge>> activeEdges)
 {
     foreach (SnapEdge edge2 in otherEdges)
     {
         if (ShouldEdgesSnap(edge, edge2))
         {
             float num = Mathf.Abs((float) (edge2.pos - edge.pos));
             if (num < maxDist)
             {
                 maxDist = num;
                 snapVal = edge2.pos - edge.pos;
                 activeEdges.Clear();
                 activeEdges.Add(new KeyValuePair<SnapEdge, SnapEdge>(edge, edge2));
             }
             else if (num == maxDist)
             {
                 activeEdges.Add(new KeyValuePair<SnapEdge, SnapEdge>(edge, edge2));
             }
         }
     }
 }
Exemplo n.º 20
0
 private void SetupWindowEdges()
 {
   Rect position = this.position;
   if (this.m_Left == null)
   {
     this.m_Left = new SnapEdge((Object) this, SnapEdge.EdgeDir.Left, position.xMin, position.yMin, position.yMax);
     this.m_Right = new SnapEdge((Object) this, SnapEdge.EdgeDir.Right, position.xMax, position.yMin, position.yMax);
     this.m_Top = new SnapEdge((Object) this, SnapEdge.EdgeDir.Up, position.yMin, position.xMin, position.xMax);
     this.m_Bottom = new SnapEdge((Object) this, SnapEdge.EdgeDir.Down, position.yMax, position.xMin, position.xMax);
   }
   this.m_Left.pos = position.xMin;
   this.m_Left.start = position.yMin;
   this.m_Left.end = position.yMax;
   this.m_Right.pos = position.xMax;
   this.m_Right.start = position.yMin;
   this.m_Right.end = position.yMax;
   this.m_Top.pos = position.yMin;
   this.m_Top.start = position.xMin;
   this.m_Top.end = position.xMax;
   this.m_Bottom.pos = position.yMax;
   this.m_Bottom.start = position.xMin;
   this.m_Bottom.end = position.xMax;
 }
Exemplo n.º 21
0
		private void SetupWindowEdges()
		{
			Rect position = this.position;
			if (this.m_Left == null)
			{
				this.m_Left = new SnapEdge(this, SnapEdge.EdgeDir.Left, position.xMin, position.yMin, position.yMax);
				this.m_Right = new SnapEdge(this, SnapEdge.EdgeDir.Right, position.xMax, position.yMin, position.yMax);
				this.m_Top = new SnapEdge(this, SnapEdge.EdgeDir.Up, position.yMin, position.xMin, position.xMax);
				this.m_Bottom = new SnapEdge(this, SnapEdge.EdgeDir.Down, position.yMax, position.xMin, position.xMax);
				for (int i = 0; i < 9; i++)
				{
					this.edges[i] = new List<SnapEdge>();
				}
				this.edges[0].Add(this.m_Top);
				this.edges[0].Add(this.m_Left);
				this.edges[1].Add(this.m_Top);
				this.edges[2].Add(this.m_Top);
				this.edges[2].Add(this.m_Right);
				this.edges[3].Add(this.m_Left);
				this.edges[4].Add(this.m_Left);
				this.edges[4].Add(this.m_Right);
				this.edges[4].Add(this.m_Top);
				this.edges[4].Add(this.m_Bottom);
				this.edges[5].Add(this.m_Right);
				this.edges[6].Add(this.m_Bottom);
				this.edges[6].Add(this.m_Left);
				this.edges[7].Add(this.m_Bottom);
				this.edges[8].Add(this.m_Bottom);
				this.edges[8].Add(this.m_Right);
			}
			this.m_Left.pos = position.xMin;
			this.m_Left.start = position.yMin;
			this.m_Left.end = position.yMax;
			this.m_Right.pos = position.xMax;
			this.m_Right.start = position.yMin;
			this.m_Right.end = position.yMax;
			this.m_Top.pos = position.yMin;
			this.m_Top.start = position.xMin;
			this.m_Top.end = position.xMax;
			this.m_Bottom.pos = position.yMax;
			this.m_Bottom.start = position.xMin;
			this.m_Bottom.end = position.xMax;
		}
Exemplo n.º 22
0
 private static bool ShouldEdgesSnap(SnapEdge a, SnapEdge b)
 {
     return((((a.dir == EdgeDir.CenterX) || (a.dir == EdgeDir.CenterY)) && (a.dir == b.dir)) || ((a.dir == OppositeEdge(b.dir)) && ((a.start <= b.end) && (a.end >= b.start))));
 }
Exemplo n.º 23
0
 private static bool ShouldEdgesSnap(SnapEdge a, SnapEdge b)
 {
     return(((a.dir == SnapEdge.EdgeDir.CenterX || a.dir == SnapEdge.EdgeDir.CenterY) && a.dir == b.dir) || (a.dir == SnapEdge.OppositeEdge(b.dir) && (a.start <= b.end && a.end >= b.start)));
 }
Exemplo n.º 24
0
		private static bool ShouldEdgesSnap(SnapEdge a, SnapEdge b)
		{
			return ((a.dir == SnapEdge.EdgeDir.CenterX || a.dir == SnapEdge.EdgeDir.CenterY) && a.dir == b.dir) || (a.dir == SnapEdge.OppositeEdge(b.dir) && (a.start <= b.end && a.end >= b.start));
		}