// border editing callback private void OnSpriteEdited(PivotEditingResult result, SVGSpriteAssetFile spriteAsset, Vector2 editedPivot, Vector4 editedBorder) { SVGCanvasBehaviour svgCanvas = target as SVGCanvasBehaviour; if ((svgCanvas != null) && (result == PivotEditingResult.Ok)) { SVGUIAtlas uiAtlas = svgCanvas.UIAtlas; if (uiAtlas != null) { // assign the new border uiAtlas.UpdateBorder(spriteAsset, editedBorder); SVGUtils.MarkObjectDirty(uiAtlas); SVGUtils.MarkSceneDirty(); // get the list of instantiated SVG sprites that reference the edited one List <GameObject> spritesInstances = new List <GameObject>(); uiAtlas.GetSpritesInstances(spritesInstances, spriteAsset.SpriteRef); foreach (GameObject gameObj in spritesInstances) { Image uiImage = (Image)gameObj.GetComponent <Image>(); if (uiImage != null) { // the Image component won't recognize the change of sprite border, so in order to refresh // instantiated objects we have to unset-set the sprite property uiImage.sprite = null; uiImage.sprite = spriteAsset.SpriteData.Sprite; } } } } }
// border editing callback private void OnSpriteEdited(PivotEditingResult result, SVGSpriteAssetFile spriteAsset, Vector2 editedPivot, Vector4 editedBorder) { SVGUISpriteLoaderBehaviour spriteLoader = target as SVGUISpriteLoaderBehaviour; if ((spriteLoader != null) && (result == PivotEditingResult.Ok)) { SVGUIAtlas uiAtlas = spriteLoader.UIAtlas; if (uiAtlas != null) { // assign the new border uiAtlas.UpdateBorder(spriteAsset, editedPivot, editedBorder); SVGUtils.MarkObjectDirty(uiAtlas); Image uiImage = spriteLoader.GetComponent <Image>(); if (uiImage != null) { // the Image component does not recognize the change of sprite border, so in order to refresh // instantiated objects we have to unset-set the sprite property uiImage.sprite = null; uiImage.sprite = spriteAsset.SpriteData.Sprite; } } } }