Exemple #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));
                 }
             }
         }
     }
 }
		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;
		}
Exemple #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;
            }
        }
Exemple #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);
 }
Exemple #5
0
 private static bool EdgeInside(SnapEdge edge, List<SnapEdge> frustum)
 {
     foreach (SnapEdge edge2 in frustum)
     {
         if (!ShouldEdgesSnap(edge, edge2))
         {
             return false;
         }
     }
     return true;
 }
Exemple #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);
 }
 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;
 }
Exemple #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);
 }
		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;
		}
        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;
        }
Exemple #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));
             }
         }
     }
 }
Exemple #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);
        }
Exemple #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;
        }
Exemple #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);
        }
 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));
       }
     }
   }
 }
Exemple #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;
            }
        }
Exemple #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))));
 }
 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;
 }
Exemple #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));
             }
         }
     }
 }
 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;
 }
		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;
		}
Exemple #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))));
 }
Exemple #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)));
 }
Exemple #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));
		}