public void RemoveRect(SpriteRect r)
 {
     if (this.m_Rects != null)
     {
         this.m_Rects.Remove(r);
     }
 }
Exemple #2
0
        public bool HandleSpriteSelection()
        {
            bool flag = false;

            if (this.m_EventSystem.current.type == EventType.MouseDown && this.m_EventSystem.current.button == 0 && GUIUtility.hotControl == 0 && !this.m_EventSystem.current.alt)
            {
                SpriteRect selectedSpriteRect = this.selectedSpriteRect;
                SpriteRect spriteRect         = this.TrySelect(this.m_EventSystem.current.mousePosition);
                if (spriteRect != selectedSpriteRect)
                {
                    Undo.RegisterCompleteObjectUndo(this, "Sprite Selection");
                    this.selectedSpriteRect = spriteRect;
                    flag = true;
                }
                if (this.selectedSpriteRect != null)
                {
                    SpriteEditorWindow.s_OneClickDragStarted = true;
                }
                else
                {
                    this.RequestRepaint();
                }
                if (flag && this.selectedSpriteRect != null)
                {
                    this.m_EventSystem.current.Use();
                }
            }
            return(flag);
        }
Exemple #3
0
 public void AddRect(SpriteRect r)
 {
     if (this.m_Rects != null)
     {
         this.m_Rects.Add(r);
     }
 }
Exemple #4
0
        private SpriteRect TrySelect(Vector2 mousePosition)
        {
            float      num        = 3.40282347E+38f;
            SpriteRect spriteRect = null;

            mousePosition = Handles.inverseMatrix.MultiplyPoint(mousePosition);
            SpriteRect result;

            for (int i = 0; i < this.m_RectsCache.Count; i++)
            {
                SpriteRect spriteRect2 = this.m_RectsCache[i];
                if (spriteRect2.rect.Contains(mousePosition))
                {
                    if (spriteRect2 == this.selectedSpriteRect)
                    {
                        result = spriteRect2;
                        return(result);
                    }
                    float width  = spriteRect2.rect.width;
                    float height = spriteRect2.rect.height;
                    float num2   = width * height;
                    if (width > 0f && height > 0f && num2 < num)
                    {
                        spriteRect = spriteRect2;
                        num        = num2;
                    }
                }
            }
            result = spriteRect;
            return(result);
        }
Exemple #5
0
        private SpriteRect TrySelect(Vector2 mousePosition)
        {
            float      selectedSize = float.MaxValue;
            SpriteRect currentRect  = null;

            mousePosition = Handles.inverseMatrix.MultiplyPoint(mousePosition);

            for (int i = 0; i < m_RectsCache.Count; i++)
            {
                var sr = m_RectsCache[i];
                if (sr.rect.Contains(mousePosition))
                {
                    // If we clicked inside an already selected spriterect, always persist that selection
                    if (sr == selectedSpriteRect)
                    {
                        return(sr);
                    }

                    float width   = sr.rect.width;
                    float height  = sr.rect.height;
                    float newSize = width * height;
                    if (width > 0f && height > 0f && newSize < selectedSize)
                    {
                        currentRect  = sr;
                        selectedSize = newSize;
                    }
                }
            }

            return(currentRect);
        }
 public void RemoveRect(SpriteRect r)
 {
     if (this.m_Rects != null)
     {
         this.m_Rects.RemoveAll((SpriteRect x) => x.spriteID == r.spriteID);
     }
 }
Exemple #7
0
 void ISpriteEditorDataProvider.SetSpriteRects(SpriteRect[] spriteRects)
 {
     if (this.spriteImportMode == SpriteImportMode.Single && spriteRects.Length == 1)
     {
         this.m_SpriteSingle.CopyFromSpriteRect(spriteRects[0]);
     }
     else if (this.spriteImportMode == SpriteImportMode.Multiple)
     {
         for (int i = this.m_SpritesMultiple.Count - 1; i >= 0; i--)
         {
             if (!spriteRects.Contains(this.m_SpritesMultiple[i]))
             {
                 this.m_SpritesMultiple.RemoveAt(i);
             }
         }
         for (int j = 0; j < spriteRects.Length; j++)
         {
             SpriteRect spriteRect = spriteRects[j];
             int        num        = this.m_SpritesMultiple.FindIndex((SpriteDataExt x) => x.spriteID == spriteRect.spriteID);
             if (num == -1)
             {
                 this.m_SpritesMultiple.Add(new SpriteDataExt(spriteRect));
             }
             else
             {
                 this.m_SpritesMultiple[num].CopyFromSpriteRect(spriteRects[j]);
             }
         }
     }
 }
 public void AddRect(SpriteRect r)
 {
     if (m_Rects != null)
     {
         m_Rects.Add(r);
     }
 }
 public void RemoveRect(SpriteRect r)
 {
     if (m_Rects != null)
     {
         m_Rects.RemoveAll(x => x.spriteID == r.spriteID);
     }
 }
		public void RemoveRect(SpriteRect r)
		{
			if (this.m_Rects != null)
			{
				this.m_Rects.Remove(r);
			}
		}
        private void AddSprite(Rect frame, int alignment, Vector2 pivot, AutoSlicingMethod slicingMethod, ref int index)
        {
            if (slicingMethod != AutoSlicingMethod.DeleteAll)
            {
                // Smart: Whenever we overlap, we just modify the existing rect and keep its other properties
                // Safe: We only add new rect if it doesn't overlap existing one

                SpriteRect existingSprite = GetExistingOverlappingSprite(frame);
                if (existingSprite != null)
                {
                    if (slicingMethod == AutoSlicingMethod.Smart)
                    {
                        existingSprite.rect      = frame;
                        existingSprite.alignment = (SpriteAlignment)alignment;
                        existingSprite.pivot     = pivot;
                    }
                }
                else
                {
                    AddSpriteWithUniqueName(frame, alignment, pivot, kDefaultColliderAlphaCutoff, kDefaultColliderDetail, index++, Vector4.zero);
                }
            }
            else
            {
                AddSprite(frame, alignment, pivot, kDefaultColliderAlphaCutoff, kDefaultColliderDetail, GetSpriteNamePrefix() + "_" + index++, Vector4.zero);
            }
        }
		public void AddRect(SpriteRect r)
		{
			if (this.m_Rects != null)
			{
				this.m_Rects.Add(r);
			}
		}
Exemple #13
0
 public bool Contains(SpriteRect spriteRect)
 {
     if (this.m_Rects != null)
     {
         return(this.m_Rects.Contains(spriteRect));
     }
     return(false);
 }
Exemple #14
0
 public void AddRect(SpriteRect r)
 {
     if (this.m_Rects == null)
     {
         return;
     }
     this.m_Rects.Add(r);
 }
		public int GetIndex(SpriteRect spriteRect)
		{
			if (this.m_Rects != null)
			{
				return this.m_Rects.FindIndex((SpriteRect p) => p.Equals(spriteRect));
			}
			return 0;
		}
Exemple #16
0
 public void RemoveRect(SpriteRect r)
 {
     if (this.m_Rects == null)
     {
         return;
     }
     this.m_Rects.Remove(r);
 }
Exemple #17
0
 public int GetIndex(SpriteRect spriteRect)
 {
     if (this.m_Rects != null)
     {
         return(this.m_Rects.FindIndex((SpriteRect p) => p.Equals(spriteRect)));
     }
     return(0);
 }
        public bool Contains(SpriteRect spriteRect)
        {
            if (m_Rects != null && spriteRect != null)
            {
                return(m_Rects.Find(x => x.spriteID == spriteRect.spriteID) != null);
            }

            return(false);
        }
        public int GetIndex(SpriteRect spriteRect)
        {
            if (m_Rects != null && spriteRect != null)
            {
                return(m_Rects.FindIndex(p => p.spriteID == spriteRect.spriteID));
            }

            return(-1);
        }
Exemple #20
0
 private void DoApply(SerializedObject so)
 {
     if (this.multipleSprites)
     {
         List <string>      list  = new List <string>();
         List <string>      list2 = new List <string>();
         SerializedProperty serializedProperty = so.FindProperty("m_SpriteSheet.m_Sprites");
         for (int i = 0; i < this.m_RectsCache.Count; i++)
         {
             SpriteRect spriteRect = this.m_RectsCache.RectAt(i);
             if (string.IsNullOrEmpty(spriteRect.name))
             {
                 spriteRect.name = "Empty";
             }
             if (!string.IsNullOrEmpty(spriteRect.originalName))
             {
                 list.Add(spriteRect.originalName);
                 list2.Add(spriteRect.name);
             }
             if (serializedProperty.arraySize < this.m_RectsCache.Count)
             {
                 serializedProperty.InsertArrayElementAtIndex(serializedProperty.arraySize);
             }
             SerializedProperty arrayElementAtIndex = serializedProperty.GetArrayElementAtIndex(i);
             spriteRect.ApplyToSerializedProperty(arrayElementAtIndex);
             EditorUtility.DisplayProgressBar(SpriteEditorWindow.SpriteEditorWindowStyles.saveProgressTitle.text, string.Format(SpriteEditorWindow.SpriteEditorWindowStyles.saveContentText.text, i, this.m_RectsCache.Count), (float)i / (float)this.m_RectsCache.Count);
         }
         while (this.m_RectsCache.Count < serializedProperty.arraySize)
         {
             serializedProperty.DeleteArrayElementAtIndex(this.m_RectsCache.Count);
         }
         if (list.Count > 0)
         {
             PatchImportSettingRecycleID.PatchMultiple(so, 213, list.ToArray(), list2.ToArray());
         }
     }
     else if (this.m_RectsCache.Count > 0)
     {
         SpriteRect spriteRect2 = this.m_RectsCache.RectAt(0);
         so.FindProperty("m_Alignment").intValue                  = (int)spriteRect2.alignment;
         so.FindProperty("m_SpriteBorder").vector4Value           = spriteRect2.border;
         so.FindProperty("m_SpritePivot").vector2Value            = spriteRect2.pivot;
         so.FindProperty("m_SpriteTessellationDetail").floatValue = spriteRect2.tessellationDetail;
         SerializedProperty serializedProperty2 = so.FindProperty("m_SpriteSheet.m_Outline");
         if (spriteRect2.outline != null)
         {
             SpriteRect.ApplyOutlineChanges(serializedProperty2, spriteRect2.outline);
         }
         else
         {
             serializedProperty2.ClearArray();
         }
     }
     EditorUtility.ClearProgressBar();
 }
Exemple #21
0
        public void LoadFromSerializedProperty(SerializedProperty sp)
        {
            this.rect               = sp.FindPropertyRelative("m_Rect").rectValue;
            this.border             = sp.FindPropertyRelative("m_Border").vector4Value;
            this.name               = sp.FindPropertyRelative("m_Name").stringValue;
            this.alignment          = (SpriteAlignment)sp.FindPropertyRelative("m_Alignment").intValue;
            this.pivot              = SpriteEditorUtility.GetPivotValue(this.alignment, sp.FindPropertyRelative("m_Pivot").vector2Value);
            this.tessellationDetail = sp.FindPropertyRelative("m_TessellationDetail").floatValue;
            SerializedProperty outlineSP = sp.FindPropertyRelative("m_Outline");

            this.outline = SpriteRect.AcquireOutline(outlineSP);
        }
Exemple #22
0
        public override bool ApplyRevert(bool apply)
        {
            if (apply)
            {
                if (containsMultipleSprites)
                {
                    var oldNames = new List <string>();
                    var newNames = new List <string>();

                    for (int i = 0; i < m_RectsCache.spriteRects.Count; i++)
                    {
                        SpriteRect spriteRect = (SpriteRect)m_RectsCache.spriteRects[i];

                        if (string.IsNullOrEmpty(spriteRect.name))
                        {
                            spriteRect.name = "Empty";
                        }

                        if (!string.IsNullOrEmpty(spriteRect.originalName))
                        {
                            oldNames.Add(spriteRect.originalName);
                            newNames.Add(spriteRect.name);
                        }
                    }
                    var so = new SerializedObject(m_SpriteDataProvider.targetObject);
                    if (oldNames.Count > 0)
                    {
                        PatchImportSettingRecycleID.PatchMultiple(so, 213, oldNames.ToArray(), newNames.ToArray());
                    }
                    so.ApplyModifiedPropertiesWithoutUndo();
                }
                m_SpriteDataProvider.SetSpriteRects(m_RectsCache?.spriteRects.ToArray());
                if (m_RectsCache != null)
                {
                    undoSystem.ClearUndo(m_RectsCache);
                }
            }
            else
            {
                if (m_RectsCache != null)
                {
                    undoSystem.ClearUndo(m_RectsCache);
                    m_RectsCache.spriteRects = m_SpriteDataProvider.GetSpriteRects().ToList();
                    spriteEditor.spriteRects = m_RectsCache.spriteRects;
                    if (spriteEditor.selectedSpriteRect != null)
                    {
                        spriteEditor.selectedSpriteRect = m_RectsCache.spriteRects.FirstOrDefault(x => x.spriteID == spriteEditor.selectedSpriteRect.spriteID);
                    }
                }
            }

            return(true);
        }
Exemple #23
0
 public void GeneratePolygonOutline()
 {
     for (int i = 0; i < this.m_RectsCache.Count; i++)
     {
         SpriteRect    spriteRect    = this.m_RectsCache.RectAt(i);
         SpriteOutline spriteOutline = new SpriteOutline();
         spriteOutline.AddRange(UnityEditor.Sprites.SpriteUtility.GeneratePolygonOutlineVerticesOfSize(this.polygonSides, (int)spriteRect.rect.width, (int)spriteRect.rect.height));
         spriteRect.outline.Clear();
         spriteRect.outline.Add(spriteOutline);
         base.spriteEditor.SetDataModified();
     }
     base.Repaint();
 }
 public int GetIndex(SpriteRect spriteRect)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: variable of a compiler-generated type
   SpriteRectCache.\u003CGetIndex\u003Ec__AnonStoreyB4 indexCAnonStoreyB4 = new SpriteRectCache.\u003CGetIndex\u003Ec__AnonStoreyB4();
   // ISSUE: reference to a compiler-generated field
   indexCAnonStoreyB4.spriteRect = spriteRect;
   if (this.m_Rects != null)
   {
     // ISSUE: reference to a compiler-generated method
     return this.m_Rects.FindIndex(new Predicate<SpriteRect>(indexCAnonStoreyB4.\u003C\u003Em__211));
   }
   return 0;
 }
 public SpriteRect AddSprite(Rect rect, int alignment, Vector2 pivot, int colliderAlphaCutoff, float colliderDetail)
 {
     SpriteRect r = new SpriteRect {
         m_Rect = rect,
         m_Alignment = (SpriteAlignment) alignment,
         m_Pivot = pivot
     };
     string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this.m_TextureImporter.assetPath);
     r.m_Name = this.GetUniqueName(fileNameWithoutExtension);
     r.m_OriginalName = r.m_Name;
     this.textureIsDirty = true;
     this.m_RectsCache.AddRect(r);
     return r;
 }
 public void GeneratePolygonOutline()
 {
     for (int i = 0; i < this.m_RectsCache.spriteRects.Count; i++)
     {
         SpriteRect spriteRect = this.m_RectsCache.spriteRects[i];
         Vector2[]  item       = UnityEditor.Sprites.SpriteUtility.GeneratePolygonOutlineVerticesOfSize(this.polygonSides, (int)spriteRect.rect.width, (int)spriteRect.rect.height);
         this.m_Outline.Clear();
         List <Vector2[]> list = new List <Vector2[]>();
         list.Add(item);
         this.m_Outline.Add(list);
         base.spriteEditor.SetDataModified();
     }
     base.Repaint();
 }
        public int GetIndex(SpriteRect spriteRect)
        {
            int result;

            if (this.m_Rects != null)
            {
                result = this.m_Rects.FindIndex((SpriteRect p) => p.Equals(spriteRect));
            }
            else
            {
                result = 0;
            }
            return(result);
        }
        public int GetIndex(SpriteRect spriteRect)
        {
            int result;

            if (this.m_Rects != null && spriteRect != null)
            {
                result = this.m_Rects.FindIndex((SpriteRect p) => p.spriteID == spriteRect.spriteID);
            }
            else
            {
                result = -1;
            }
            return(result);
        }
Exemple #29
0
 public int GetIndex(SpriteRect spriteRect)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     SpriteRectCache.\u003CGetIndex\u003Ec__AnonStoreyB4 indexCAnonStoreyB4 = new SpriteRectCache.\u003CGetIndex\u003Ec__AnonStoreyB4();
     // ISSUE: reference to a compiler-generated field
     indexCAnonStoreyB4.spriteRect = spriteRect;
     if (this.m_Rects != null)
     {
         // ISSUE: reference to a compiler-generated method
         return(this.m_Rects.FindIndex(new Predicate <SpriteRect>(indexCAnonStoreyB4.\u003C\u003Em__211)));
     }
     return(0);
 }
Exemple #30
0
 private void DeterminePolygonSides()
 {
     if (this.polygonSprite && this.m_RectsCache.Count == 1)
     {
         SpriteRect spriteRect = this.m_RectsCache.RectAt(0);
         if (spriteRect.outline.Count == 1)
         {
             this.polygonSides = spriteRect.outline[0].Count;
         }
     }
     else
     {
         this.polygonSides = 0;
     }
 }
        private SpriteRect AddSprite(Rect rect, int alignment, Vector2 pivot, int colliderAlphaCutoff, float colliderDetail, string name)
        {
            SpriteRect spriteRect = new SpriteRect();

            spriteRect.rect         = rect;
            spriteRect.alignment    = (SpriteAlignment)alignment;
            spriteRect.pivot        = pivot;
            spriteRect.name         = name;
            spriteRect.originalName = spriteRect.name;
            spriteRect.border       = Vector4.zero;
            base.spriteEditor.SetDataModified();
            this.m_RectsCache.spriteRects.Add(spriteRect);
            base.spriteEditor.SetDataModified();
            return(spriteRect);
        }
 public override void OnModuleActivate()
 {
     base.OnModuleActivate();
     this.m_Outline = new List <List <Vector2[]> >();
     for (int i = 0; i < this.m_RectsCache.spriteRects.Count; i++)
     {
         SpriteRect spriteRect = this.m_RectsCache.spriteRects[i];
         this.m_Outline.Add(base.spriteEditor.GetDataProvider <ISpriteOutlineDataProvider>().GetOutlines(spriteRect.spriteID));
     }
     this.showChangeShapeWindow = this.polygonSprite;
     if (this.polygonSprite)
     {
         this.DeterminePolygonSides();
     }
 }
Exemple #33
0
        public void ApplyToSerializedProperty(SerializedProperty sp)
        {
            sp.FindPropertyRelative("m_Rect").rectValue                = this.rect;
            sp.FindPropertyRelative("m_Border").vector4Value           = this.border;
            sp.FindPropertyRelative("m_Name").stringValue              = this.name;
            sp.FindPropertyRelative("m_Alignment").intValue            = (int)this.alignment;
            sp.FindPropertyRelative("m_Pivot").vector2Value            = this.pivot;
            sp.FindPropertyRelative("m_TessellationDetail").floatValue = this.tessellationDetail;
            SerializedProperty serializedProperty = sp.FindPropertyRelative("m_Outline");

            serializedProperty.ClearArray();
            if (this.outline != null)
            {
                SpriteRect.ApplyOutlineChanges(serializedProperty, this.outline);
            }
        }
Exemple #34
0
        public void GeneratePolygonOutline()
        {
            for (int i = 0; i < m_RectsCache.spriteRects.Count; i++)
            {
                SpriteRect currentRect = m_RectsCache.spriteRects[i];

                var result = UnityEditor.Sprites.SpriteUtility.GeneratePolygonOutlineVerticesOfSize(polygonSides, (int)currentRect.rect.width, (int)currentRect.rect.height);

                m_Outline.Clear();
                var newOutlineList = new List <Vector2[]>();
                newOutlineList.Add(result);
                m_Outline.Add(newOutlineList);

                spriteEditor.SetDataModified();
            }
            Repaint();
        }
Exemple #35
0
        private void InitSelectedSpriteRect()
        {
            SpriteRect selectedSpriteRect = null;

            if (this.m_RectsCache != null && this.m_RectsCache.Count > 0)
            {
                if (this.selectedSpriteRect != null)
                {
                    selectedSpriteRect = ((this.m_RectsCache.FirstOrDefault((SpriteRect x) => x.spriteID == this.selectedSpriteRect.spriteID) == null) ? this.m_RectsCache[0] : this.selectedSpriteRect);
                }
                else
                {
                    selectedSpriteRect = this.m_RectsCache[0];
                }
            }
            this.selectedSpriteRect = selectedSpriteRect;
        }
 private bool ShouldDrawBorders(SpriteRect currentRect)
 {
   if (!Mathf.Approximately(currentRect.m_Border.sqrMagnitude, 0.0f))
     return true;
   if (currentRect == this.selected)
     return this.m_GizmoMode == SpriteEditorWindow.GizmoMode.BorderEditing;
   return false;
 }
		private bool ShouldDrawBorders(SpriteRect currentRect)
		{
			Vector4 border = currentRect.m_Border;
			return !Mathf.Approximately(border.sqrMagnitude, 0f) || (currentRect == this.selected && this.m_GizmoMode == SpriteEditorWindow.GizmoMode.BorderEditing);
		}
 private static void AcquireOutline(SerializedProperty outlineSP, SpriteRect spriteRect)
 {
   for (int index1 = 0; index1 < outlineSP.arraySize; ++index1)
   {
     List<Vector2> vector2List = new List<Vector2>();
     SerializedProperty arrayElementAtIndex = outlineSP.GetArrayElementAtIndex(index1);
     for (int index2 = 0; index2 < arrayElementAtIndex.arraySize; ++index2)
     {
       Vector2 vector2Value = arrayElementAtIndex.GetArrayElementAtIndex(index2).vector2Value;
       vector2List.Add(vector2Value);
     }
     spriteRect.m_Outline.Add(vector2List);
   }
 }
 private static void ApplyOutlineChanges(SerializedProperty outlineSP, SpriteRect spriteRect)
 {
   outlineSP.ClearArray();
   for (int index1 = 0; index1 < spriteRect.m_Outline.Count; ++index1)
   {
     outlineSP.InsertArrayElementAtIndex(index1);
     SerializedProperty arrayElementAtIndex = outlineSP.GetArrayElementAtIndex(index1);
     arrayElementAtIndex.ClearArray();
     List<Vector2> vector2List = spriteRect.m_Outline[index1];
     for (int index2 = 0; index2 < vector2List.Count; ++index2)
     {
       arrayElementAtIndex.InsertArrayElementAtIndex(index2);
       arrayElementAtIndex.GetArrayElementAtIndex(index2).vector2Value = vector2List[index2];
     }
   }
 }
 public bool Contains(SpriteRect spriteRect)
 {
   if (this.m_Rects != null)
     return this.m_Rects.Contains(spriteRect);
   return false;
 }
 public void AddRect(SpriteRect r)
 {
   if (this.m_Rects == null)
     return;
   this.m_Rects.Add(r);
 }
		private void RefreshRects()
		{
			if (this.m_TextureImporterSprites == null)
			{
				return;
			}
			if (this.m_RectsCache)
			{
				this.m_RectsCache.ClearAll();
				UnityEngine.Object.DestroyImmediate(this.m_RectsCache);
			}
			this.m_RectsCache = ScriptableObject.CreateInstance<SpriteRectCache>();
			if (this.multipleSprites)
			{
				for (int i = 0; i < this.m_TextureImporterSprites.arraySize; i++)
				{
					SpriteRect spriteRect = new SpriteRect();
					spriteRect.m_Rect = this.m_TextureImporterSprites.GetArrayElementAtIndex(i).FindPropertyRelative("m_Rect").rectValue;
					spriteRect.m_Name = this.m_TextureImporterSprites.GetArrayElementAtIndex(i).FindPropertyRelative("m_Name").stringValue;
					spriteRect.m_Alignment = (SpriteAlignment)this.m_TextureImporterSprites.GetArrayElementAtIndex(i).FindPropertyRelative("m_Alignment").intValue;
					spriteRect.m_Border = this.m_TextureImporterSprites.GetArrayElementAtIndex(i).FindPropertyRelative("m_Border").vector4Value;
					spriteRect.m_Pivot = SpriteEditorUtility.GetPivotValue(spriteRect.m_Alignment, this.m_TextureImporterSprites.GetArrayElementAtIndex(i).FindPropertyRelative("m_Pivot").vector2Value);
					this.m_RectsCache.AddRect(spriteRect);
				}
			}
			else
			{
				SpriteRect spriteRect2 = new SpriteRect();
				spriteRect2.m_Rect = new Rect(0f, 0f, (float)this.m_Texture.width, (float)this.m_Texture.height);
				spriteRect2.m_Name = this.m_OriginalTexture.name;
				spriteRect2.m_Alignment = (SpriteAlignment)this.m_TextureImporterSO.FindProperty("m_Alignment").intValue;
				spriteRect2.m_Border = this.m_TextureImporter.spriteBorder;
				spriteRect2.m_Pivot = SpriteEditorUtility.GetPivotValue(spriteRect2.m_Alignment, this.m_TextureImporter.spritePivot);
				this.m_RectsCache.AddRect(spriteRect2);
			}
			if (this.m_RectsCache.Count > 0)
			{
				this.selected = this.m_RectsCache.RectAt(0);
			}
		}
		public bool Contains(SpriteRect spriteRect)
		{
			return this.m_Rects != null && this.m_Rects.Contains(spriteRect);
		}
 public void RemoveRect(SpriteRect r)
 {
   if (this.m_Rects == null)
     return;
   this.m_Rects.Remove(r);
 }
 private void RefreshRects()
 {
   if (this.m_TextureImporterSprites == null)
     return;
   if ((bool) ((UnityEngine.Object) this.m_RectsCache))
   {
     this.m_RectsCache.ClearAll();
     Undo.ClearUndo((UnityEngine.Object) this.m_RectsCache);
     UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_RectsCache);
   }
   this.m_RectsCache = ScriptableObject.CreateInstance<SpriteRectCache>();
   if (this.multipleSprites)
   {
     for (int index = 0; index < this.m_TextureImporterSprites.arraySize; ++index)
     {
       SpriteRect spriteRect = new SpriteRect();
       spriteRect.m_Rect = this.m_TextureImporterSprites.GetArrayElementAtIndex(index).FindPropertyRelative("m_Rect").rectValue;
       spriteRect.m_Name = this.m_TextureImporterSprites.GetArrayElementAtIndex(index).FindPropertyRelative("m_Name").stringValue;
       spriteRect.m_Alignment = (SpriteAlignment) this.m_TextureImporterSprites.GetArrayElementAtIndex(index).FindPropertyRelative("m_Alignment").intValue;
       spriteRect.m_Border = this.m_TextureImporterSprites.GetArrayElementAtIndex(index).FindPropertyRelative("m_Border").vector4Value;
       spriteRect.m_Pivot = SpriteEditorUtility.GetPivotValue(spriteRect.m_Alignment, this.m_TextureImporterSprites.GetArrayElementAtIndex(index).FindPropertyRelative("m_Pivot").vector2Value);
       SpriteEditorWindow.AcquireOutline(this.m_TextureImporterSprites.GetArrayElementAtIndex(index).FindPropertyRelative("m_Outline"), spriteRect);
       this.m_RectsCache.AddRect(spriteRect);
     }
   }
   else if (this.validSprite)
   {
     SpriteRect spriteRect = new SpriteRect();
     spriteRect.m_Rect = new Rect(0.0f, 0.0f, (float) this.m_Texture.width, (float) this.m_Texture.height);
     spriteRect.m_Name = this.m_OriginalTexture.name;
     spriteRect.m_Alignment = (SpriteAlignment) this.m_TextureImporterSO.FindProperty("m_Alignment").intValue;
     spriteRect.m_Border = this.m_TextureImporter.spriteBorder;
     spriteRect.m_Pivot = SpriteEditorUtility.GetPivotValue(spriteRect.m_Alignment, this.m_TextureImporter.spritePivot);
     SpriteEditorWindow.AcquireOutline(this.m_SpriteSheetOutline, spriteRect);
     this.m_RectsCache.AddRect(spriteRect);
   }
   if (this.m_RectsCache.Count <= 0)
     return;
   this.selected = this.m_RectsCache.RectAt(0);
 }
		public SpriteRect AddSprite(Rect rect, int alignment, int colliderAlphaCutoff, float colliderDetail)
		{
			SpriteRect spriteRect = new SpriteRect();
			spriteRect.m_Rect = rect;
			spriteRect.m_Alignment = (SpriteAlignment)alignment;
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this.m_TextureImporter.assetPath);
			spriteRect.m_Name = this.GetUniqueName(fileNameWithoutExtension);
			this.textureIsDirty = true;
			this.m_RectsCache.AddRect(spriteRect);
			return spriteRect;
		}