void OnWillRenderObject() { bool needUpdateSpriteArrays = NeedUpdateSpriteArrays(); bool spriteShapeParametersChanged = UpdateSpriteShapeParameters(); bool splineChanged = HasSplineChanged(); if (needUpdateSpriteArrays || spriteShapeParametersChanged || splineChanged) { BakeMesh(needUpdateSpriteArrays); } m_CurrentSpriteShape = spriteShape; }
void OnWillRenderObject() { ValidateSpriteShapeData(); bool needUpdateSprites = NeedUpdateSprites(); bool spriteShapeParametersChanged = UpdateSpriteShapeParameters(); bool splineChanged = HasSplineChanged(); BakeCollider(); if (needUpdateSprites || spriteShapeParametersChanged || splineChanged) { BakeMesh(needUpdateSprites); } m_ActiveSpriteShape = spriteShape; }
bool HasSpriteShapeDataChanged() { bool updateSprites = HasSpriteShapeChanged(); if (spriteShape) { var hashCode = SpriteShape.GetSpriteShapeHashCode(spriteShape); if (spriteShapeHashCode != hashCode) { m_ActiveSpriteShapeHash = hashCode; updateSprites = true; } } return updateSprites; }
private List <ShapeAngleRange> GetAngleRangeSorted(UnityEngine.U2D.SpriteShape ss) { List <ShapeAngleRange> angleRanges = new List <ShapeAngleRange>(); int i = 0; foreach (var angleRange in ss.angleRanges) { ShapeAngleRange sar = new ShapeAngleRange() { start = angleRange.start, end = angleRange.end, order = angleRange.order, index = i }; angleRanges.Add(sar); i++; } angleRanges.Sort((a, b) => a.order.CompareTo(b.order)); return(angleRanges); }
public static void SetShapeFromAsset(SpriteShapeController spriteShapeController) { UnityEngine.U2D.SpriteShape spriteShape = spriteShapeController.spriteShape; if (!spriteShape) { SpriteShapeEditorUtility.SetToSquare(spriteShapeController); return; } if (spriteShape.angleRanges.Count == 1 && spriteShape.angleRanges[0].end - spriteShape.angleRanges[0].start == 360f) { SpriteShapeEditorUtility.SetToLine(spriteShapeController); } else if (spriteShape.angleRanges.Count < 8) { SpriteShapeEditorUtility.SetToSquare(spriteShapeController); } else { SpriteShapeEditorUtility.SetToOctogon(spriteShapeController); } }
public static void CreateNewSpriteStrip() { UnityEngine.U2D.SpriteShape newSpriteShape = SpriteShapeEditorUtility.CreateSpriteShapeAsset(); newSpriteShape.angleRanges.Add(CreateAngleRange(-180.0f, 180.0f, 0)); }
public static int GetRangeIndexFromAngle(UnityEngine.U2D.SpriteShape spriteShape, float angle) { return(GetRangeIndexFromAngle(spriteShape.angleRanges, angle)); }
void OnReset(UnityEngine.U2D.SpriteShape obj) { InitCache(); }