Author Topic: UISprite  (Read 51367 times)

zs_3718

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UISprite
« Reply #30 on: November 22, 2014, 01:23:06 AM »
Maybe someone in my company modified the code...Thank you. :)

eppz!

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UISprite
« Reply #31 on: September 01, 2015, 04:21:56 PM »
What is the best way to inactivate a Sprite (a lot of)?

I have a huge bulk (120) of UISprite in a UIScrollView, also have multitude (7) of such scroll views. In the "frontmost" scroll view I use NGUI culling, but the rest of the scroll views should be inactive.

Currently I'm turning GameObjects On / Off. This way the drawcalls gets destroyed, the widgets won't get updated, childrens get inactivated as well. Beside some performance penalty, another drawback here is that I cannot adjust the dimensions / position of inactive widgets this way.

I'm just wondering if turning off Components only, or mark UISprites somehow not to render could be more efficient? Some way to preserve / reuse drawcalls, only mark them not to render?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UISprite
« Reply #32 on: September 06, 2015, 05:54:13 PM »
You can set their alpha to 0. This way their dimensions will update, but they won't be added to draw calls.

eppz!

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UISprite
« Reply #33 on: September 06, 2015, 06:59:21 PM »
Wow, thanks!

Does it affect children down along the hierarchy?
Can I spare CPU (Behaviour.Update) this way as well?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UISprite
« Reply #34 on: September 13, 2015, 06:17:05 AM »
UI is cumulative, so setting the parent to 0 hides all children. Update calls will still be called, as will anchoring logic, but drawing/rebuilding logic won't be.

Bobbin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: UISprite
« Reply #35 on: November 04, 2015, 05:32:10 AM »
I'm trying to create a tiled sprite and I find that, at least with the version that I have, my options are rather limited.

I would have preferred a way to shrink the sprite in one dimension and tile in another but I've worked around that.

My main problem now is that it seems like it's tiling from the wrong direction. It's tiling from bottom left when I want it to start from the top left. Is there a setting for that that I missed or is this not an option?
No one ever said being a Heretic was easy.
So may we meet in Less Interesting Times.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UISprite
« Reply #36 on: November 04, 2015, 01:34:04 PM »
You will need to create your own custom widget then. Derive from UISprite and overwrite the OnFill function. Base its logic on UIBasicSprite.TiledFill, but change its origin.

i_am_kisly

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UISprite
« Reply #37 on: May 14, 2016, 08:09:54 AM »
Hello
For me it was somewhat surprising that UISprite.spriteName is case-sensitive. While the search is not case-sensitive in the Atlas window. To understand this it took me a couple of hours (after all the documentation on this is not a word). Please correct or documentation or UISprite.spriteName.set.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UISprite
« Reply #38 on: May 14, 2016, 07:04:43 PM »
Code is always code sensitive. The search field is not sensitive merely for convenience.

Dune

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UISprite
« Reply #39 on: October 21, 2016, 12:16:59 AM »
Having trouble getting the sprite to change for instantiated sprite.

  1. public void SetCharacterInfo(CharacterInfo info)
  2. {
  3.     this.CharacterInfo = info;
  4.     var image = GetComponentInChildren<UISprite>();
  5.     //var atlas = image.atlas;
  6.     image.spriteName = info.sprite.name;
  7.  
  8.     var label = GetComponentInChildren<UILabel>();
  9.     label.text = transform.name = info.name;
  10. }

Everything else updates alright. I've verified that the atlas is correct, and the names match. Do I have to call a refresh of some kind on the sprite?

Dune

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UISprite
« Reply #40 on: October 21, 2016, 03:44:48 PM »
Never mind on that. I was targeting the wrong UISprite. Didn't notice until now that I was losing the parent sprites "Flat Outline."

Here's the updated code if anyone's interested...

  1. public void SetCharacterInfo(CharacterInfo info)
  2. {
  3.     this.CharacterInfo = info;
  4.     var image = GetComponentsInChildren<UISprite>()
  5.         .First(sprite => sprite.transform.name == "Image");
  6.        
  7.     //var atlas = image.atlas;
  8.     image.spriteName = info.sprite.name;
  9.  
  10.     var label = GetComponentInChildren<UILabel>();
  11.     label.text = transform.name = info.name;
  12. }
  13.  

tvhnet

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UISprite
« Reply #41 on: December 16, 2016, 02:03:57 AM »
How can I do this both in UISprite at the same time: "Sliced" and "Filled"?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UISprite
« Reply #42 on: December 19, 2016, 11:28:24 PM »
Change its type to Advanced.

tvhnet

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UISprite
« Reply #43 on: December 26, 2016, 03:56:06 AM »
There is no option to use "Filled" feature if type is in Advanced mode. It seems to not support in UISprite.

One more question: I have 2 UISprites which have the same sprite name and atlas and put in the same panel. If I set them the same depth, there is only one draw call. But if I set their depth differently, it is 2 draw calls. How to make 1 draw call in later case?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UISprite
« Reply #44 on: December 26, 2016, 05:14:53 AM »
Oh, sorry misunderstood you somehow. No, you indeed can't have both sliced and filled. Advanced mode lets you tile some parts and slice others, but filled will always affect the entire sprite and doesn't mix with the 9-slicing.

If 2 sprites are underneath the same panel, use the same atlas, and there is nothing in between their depths, then they should end up in the same draw call. You can check the draw call tool to see what got in between of your two sprites, and make sure you indeed don't have another panel there somewhere.