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 static void ApplyOutlineChanges(SerializedProperty outlineSP, List <SpriteOutline> outline) { outlineSP.ClearArray(); for (int i = 0; i < outline.Count; i++) { outlineSP.InsertArrayElementAtIndex(i); SpriteOutline spriteOutline = outline[i]; SerializedProperty arrayElementAtIndex = outlineSP.GetArrayElementAtIndex(i); arrayElementAtIndex.ClearArray(); for (int j = 0; j < spriteOutline.Count; j++) { arrayElementAtIndex.InsertArrayElementAtIndex(j); arrayElementAtIndex.GetArrayElementAtIndex(j).vector2Value = spriteOutline[j]; } } }
public static List <SpriteOutline> AcquireOutline(SerializedProperty outlineSP) { List <SpriteOutline> list = new List <SpriteOutline>(); for (int i = 0; i < outlineSP.arraySize; i++) { SpriteOutline spriteOutline = new SpriteOutline(); SerializedProperty arrayElementAtIndex = outlineSP.GetArrayElementAtIndex(i); for (int j = 0; j < arrayElementAtIndex.arraySize; j++) { Vector2 vector2Value = arrayElementAtIndex.GetArrayElementAtIndex(j).vector2Value; spriteOutline.Add(vector2Value); } list.Add(spriteOutline); } return(list); }