Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - The-Arrival

Pages: [1] 2
1
NGUI 3 Documentation / Re: Tweens
« on: May 03, 2017, 03:34:58 PM »
I´m one step closer i guess and i exactly witnessed the situation in were it happens:

The last time that bugging tween worked was in a special situation. it was set to start roughly equals and and duration 0. As soon as the tween gets started it pretty much immediatly ends. That is on purpose and fine so far!
The next time that tween gets used though i starts to bu and instantly ends it´s animation, even it gets setup with start NOT equals end and duration = 5f;
It seems we have some weired racing condition going on here. My Debug.Log states the correct setup. I was even able to move to the exact frame that tween gets setup and started using the frame-by-frame debugging. In the frame it gets started, the inspector shows the duration of 5f, but my guess is, that it´s still starting with 0f from the last time. If i go one frame further it immediatly ends, calling the OnFinish callback.

I added a little offset to my durations of 0.1f to avoid the 0f duration and voilá, the bug is gone and the tween is behaving correctly.

I hope that helps you tracking down whats going wrong here

2
NGUI 3 Documentation / Re: Tweens
« on: May 02, 2017, 02:20:44 PM »
Log Entrys and Debug.Log calls:
I was adding the debug.log call directly in to the DoUpdate funktion in the UItweener... right after delat and time get set

  1. protected void DoUpdate ()
  2.         {
  3.                 float delta = ignoreTimeScale && !useFixedUpdate ? Time.unscaledDeltaTime : Time.deltaTime;
  4.                 float time = ignoreTimeScale && !useFixedUpdate ? Time.unscaledTime : Time.time;
  5.  
  6.         Debug.Log("delta: " + delta + ", time: " + time);
  7.  
  8.  

There are two identical entrys due to the fact that there is more then one tween active and posting their logs.

Enable/Disable:

As you can see in the code i don´t enable/disable the tween component, i only enable/disable a sprite-component and a child gameobject.

Sorry for the little delay in my answers but i´m currently jumping between projects. I´ll answer more frequently from now on.

One strange behaviour i found is, that i get a few of those Debug.Log calls with time and delta, whenever i hover over an UI Element. That might be due to the fact that you use the UITweener class also for button animations? In any case that facts makes it hard for me to use the IDE-Debugger to step through the code

Did you run some tests on your own with reusing/pooling the same tween?

3
NGUI 3 Documentation / Re: Tweens
« on: April 26, 2017, 01:28:51 AM »
Hi,

yes i did call ResetToBeginning() and tried it on different positions. Right before PlayForward(), right after PlayForward() and in a callback method triggered by the OnFinished Event from your tweener.
I also tried myTransform.localPosition = startPosition in combination with myTweener.SetStartToCurrentValue();

Here are the three main methods currently used. i left the commented calls in, so you get an idea at which positions i tried resets:

  1. public void Setup(PublicEnums.Enemys enemy, bool shield, bool armor, Vector3 startPos, float duration) {
  2.         useCounter++;
  3.  
  4.         //Debug.Log("Setup Sprite: " + myID);
  5.         myRoot.localPosition = startPos;
  6.         mySprite.spriteName = SpriteUtils.getEnemyIconName(enemy);
  7.        
  8.         //Shield and Armor
  9.         if (armor) {
  10.             mySprite.color = Managers.PrefabManager.ui_armorColor;
  11.         }
  12.         if (shield) {
  13.             myShield.SetActive(true);
  14.         }
  15.  
  16.         isUsed = true;
  17.         mySprite.enabled = true;
  18.         myTweener.SetStartToCurrentValue();
  19.         myTweener.duration = duration;
  20.         myTweener.from = startPos;
  21.         myTweener.to = myEndPos;
  22.         //myTweener.ResetToBeginning();
  23.         //Debug.Log("Setup " + myID + ": start: " + startPos + ", duration: " + duration);
  24.     }
  25.     public void StartTween() {
  26.        
  27.         Debug.Log("Setup " + myID + ", pos: " + myRoot.localPosition + ": start: " + myTweener.from + ", end : " + myTweener.to + ", duration: " + myTweener.duration);
  28.         //myTweener.ResetToBeginning();
  29.         myTweener.PlayForward();
  30.         //myTweener.ResetToBeginning();
  31.     }
  32.  
  33.     public void onTweenFinished() {
  34.         myTweener.ResetToBeginning();
  35.         Debug.Log("OnTweenFinished: " + myID);
  36.         isUsed = false;
  37.         mySprite.enabled = false;
  38.         myRoot.localPosition = Vector3.zero;
  39.         myShield.SetActive(false);
  40.         mySprite.color = Color.white;
  41.     }
  42.  

Besides the Debuglogs you can see in the code samples i also added the ones you requested and another one when a tween gets reused from the pool (which is basically invisible and flagged tweens). In the attached screenshot you can see a debuglog output at the time the bug occures.

we use and setup a tween with the ID -47456. It has the right pos, start, end and duration values. three DoUpdates() later the OnFinished Events happen and my OnTweenFinished event is called

4
NGUI 3 Documentation / Re: Tweens
« on: April 16, 2017, 06:09:07 PM »
Hey Aren,

i have the following situation:
Unity 5.5.1f3
NGUI 3.11.2

I´m making a TowerDefense Game

i have a pool of sprites in my UI, all of them carry a tweenposition (disabled by default, so they not play instantly). When a sprite is requested, it gets setup (which sprite to show), the tween gets configured (start/end pos and duration) and the tween is Played forward.
OnTweenFinish the tween gets back into the bool (which means mainly it gets flagged as pooled and the sprite gets disabled.
The tween is set to NOT ignore timeScale (since we have time warp effects and the UI also should animate faster for this very panel)

Most of the time that works fine, but at some point the tweens start to play instantatiously, even the setup is correct (start != end, duration != 0)

As stated in my last post/quote i also tried differen versions of the play/rest combinations.

i used tween.PlayForward() as well as tween.Play(true)
i tried different versions of resetting the tween, like right before or after the play call as well as in the onTweenFinished Callback.

The bug allways happens at the same time, right after the first Wave is finished... in the second Wave the Bug allready is there. So it might be that it´s my fault, but i´m checking my code since hours and i can´t find the difference between wave1 and wave2 and my usage of the tweens.

Any idea what i might do wrong or could that actually be a NGUI bug?

Thanks in advance!

EDIT:

after some additional tests it became more likely that it´s an issue with NGUI.

In my usecase the poolsize was 10 and i reused more or less the same 3 items. at the time the bug occured i was reusing an item whos tween got finished right before it got claimed and used again. So what i did is to make sure that the whole pool got used, before reusing the same item again.
That time the tweens work for much longer (more waves, so it was nothing which happened between wave 1 and 2).
But it got locked again after the first item got reused about 7-8 times... maybe some racing conditions which only sometimes occure?

5
NGUI 3 Documentation / Re: Tweens
« on: November 05, 2016, 08:08:54 AM »
Ran into an issue trying to re-play a tween with code, I was trying to replay the tween with...
  1. tween.ResetToBeginning();
  2. tween.PlayForward();
This worked, but only if I set ignoreTimeScale off for some reason. Otherwise the tween would complete instantly.
From looking at UIPlayTween the following is correct. (And indeed works fine)
  1. tween.PlayForward();
  2. tween.ResetToBeginning();
Thought I'd point this out as it didn't seem obvious to me.

Thanks... this info was very helpful!

Also if you want to manually (re)set a tween to it´s from state, use: tween.Sample(0, true);

6
NGUI 3 Documentation / Re: UICamera
« on: October 17, 2016, 07:29:20 PM »
Hey...
i have a weired problem lately and no idea were this came from. I´m running Unity 5.4.x and NGUI 3.10.2

Setup:
- I have a UICamera with the EventMask set to the UI Layer
- My MainCamera also has the UICamera Component set to some a "GameObject layer" wich is set on some clickable objects in my scenes.
- I´m in Debug mode to follow which objects get triggered while hover.

In one Scene everything is working as intended: if the mouse is on an UI element, i get the UI-widget. If the button is over an object i get that object. When i hover over nothing i get the root UI object. Thas basically what i want

In a second scene everthing is setup similar, but if i hover nothing it detects the MainCamera itself. The other strange thing (besides two similar scenes have diffrent behaviors) is that the maincamera object is on "default" layer which is not included in any events mask.

Any idea what might be wrong here?

7
NGUI 3 Support / onTooltip on disabled Buttons
« on: May 15, 2016, 08:07:13 AM »
Hey Aren,

in my buildmenu evey build´button has a tooltip and gets disabled, when the player can´t affort it. Disabling a Button the NGUI-way (so that the diffrent coloring works and such) means, that the collider gets disabled, which also will disable the tooltip.

How is this tooltip/disable buttons system meant to be used for such a case? Or do i need to build a workaround for it?

P.S.:
i just checked Winward. For the abilities menu i guess you are disabling those buttons not with button.isEnebaled = false, right?

8
NGUI 3 Support / Re: Use premade Spritesheet to create an Atlas
« on: May 15, 2016, 07:49:44 AM »
That way i´ll add another texture to the Atlas and to the spitesheet-texture, i know that. I was looking for a way to "Add" a sprites locationsetting when i allready have those sprites in my spritesheet-texture and i want to define manually their locations and spacing.

9
NGUI 3 Support / Re: Use premade Spritesheet to create an Atlas
« on: May 07, 2016, 11:41:40 AM »
I still don´t find any button to add another sprite (or better another location/setting for a sprite) in the atlas maker.
 

10
NGUI 3 Support / Use premade Spritesheet to create an Atlas
« on: April 28, 2016, 04:20:43 AM »
Hello,

i have a premade texture with several sprites from my artist and i try to figure out oh to set it up as a texture atlas. I pretty much know what i need to do, except the options seem not to be available in the Atlasmaker tool, so propably i´m missing something here.

using:
Unity 5.3.3f1
NGU 3.9.8
NGU HUD Text 1.13

Here are my steps so far:

i importet the png as a texture, alphaIsTransparency checked, WarpMode clamped and truecolor as suggested here: http://www.tasharen.com/?page_id=120

i opened the atlasMaker created a new Atlas and setup the material using this very texture. Now i have one sprite to map out which i did. As stated here i should be able to setup more sprites and positions for that texture but i cannot find the button for it: http://www.tasharen.com/forum/index.php?topic=221.msg1090#msg1090

Also i get a console error. All my Settings and the error are on the attached screenshot

I also read up that it´s possible to import the sprite-positions using a txt file generated from some tool. Is there another way to generate that file or can i get an example of the layout of such a txt, so i can write my own and use it?

11
NGUI 3 Documentation / Re: UIScrollBar
« on: February 19, 2016, 04:01:27 AM »
Is it possible to subscribe to the ValueChange a FloatEvent, passing around the changed Value?

I checked your Slider example and the SetCurrentPercent method pulls the value from the slider itself.

i also tried thsi, but for sure it allways passes the same value saved on subscription

  1. EventDelegate del = new EventDelegate(ui, "SpeedChange");
  2.         del.parameters[0].value = scrollBar.value;
  3.         EventDelegate.Set(scrollBar.onChange, del);
  4.  

12
NGUI 3 Support / Re: Add onTooltip to UIEventTrigger
« on: February 08, 2016, 10:02:19 PM »
Sorry for the Spam, but i figured it out for the Index. i had to copy the iterator to a new in, otherwise all delegates hold the reference to tzhe iterator which indeed goes one step further then the loop :)

Leaves me still with the question on how to unsubscribe those anonymous delegates. Obviously it´s not recommended to use them if you wanna do so:

Quote
It is important to notice that you cannot easily unsubscribe from an event if you used an anonymous function to subscribe to it. To unsubscribe in this scenario, it is necessary to go back to the code where you subscribe to the event, store the anonymous method in a delegate variable, and then add the delegate to the event. In general, we recommend that you do not use anonymous functions to subscribe to events if you will have to unsubscribe from the event at some later point in your code. For more information about anonymous functions, see Anonymous Functions (C# Programming Guide).
"Solution" so far looks like this now:

  1. private void SubOnTooltip(bool subscribe)
  2.     {
  3.         for (int i = 0; i < staticBuild.transform.childCount; i++)
  4.         {
  5.             if (subscribe)
  6.             {
  7.                 int copy = i;
  8.                 GameObject btn = staticBuild.transform.GetChild(i).GetComponent<UIButton>().gameObject;
  9.                 Debug.Log("Button: " + btn + ", Index: " + i);
  10.                 UIEventListener.Get(btn).onTooltip += delegate(GameObject go, bool show) { ShowToolTip(go, show, copy); };
  11.             }
  12.             else
  13.             {
  14.                 int copy = i;
  15.                 GameObject btn = staticBuild.transform.GetChild(i).GetComponent<UIButton>().gameObject;
  16.                 UIEventListener.Get(btn).onTooltip -= delegate(GameObject go, bool show) { ShowToolTip(go, show, copy); };
  17.             }
  18.         }
  19.     }
  20.  

13
NGUI 3 Support / Re: Add onTooltip to UIEventTrigger
« on: February 08, 2016, 09:00:19 PM »
Well, unfortunally what i posted seems NOT to work as expected. I can print your Debug Message as you did, but the subscription to the delegate doesn´t work with the index.

I´m setting up 3 Buttons like this (with subscribe = true):

  1. private void SubOnTooltip(bool subscribe)
  2.     {
  3.         for (int i = 0; i < staticBuild.transform.childCount; i++)
  4.         {
  5.             if (subscribe)
  6.             {
  7.                
  8.                 GameObject btn = staticBuild.transform.GetChild(i).GetComponent<UIButton>().gameObject;
  9.                 Debug.Log("Index: " + i);
  10.                 UIEventListener.Get(btn).onTooltip = delegate(GameObject go, bool show) { ShowToolTip(go, show, i); };
  11.             }
  12.             else
  13.             {
  14.                 GameObject btn = staticBuild.transform.GetChild(i).GetComponent<UIButton>().gameObject;
  15.                 UIEventListener.Get(btn).onTooltip -= delegate(GameObject go, bool show) { ShowToolTip(go, show, i); };
  16.             }
  17.         }
  18.     }
  19.  

First of all, the subscribe = false case is not working out yet. Can you help me with that?

Besides this the subscription works, i get the i´s from 0-2. But when i recieve the events, all index from all buttons are 3?

  1. public void ShowToolTip(GameObject go, bool state, int index)
  2.     {
  3.        Debug.Log("index: " + index);
  4.      }
  5.  

I bet it´s something supersimple but i can´t make sense of the index 3 which i recieve

14
NGUI 3 Support / Re: Add onTooltip to UIEventTrigger
« on: February 07, 2016, 08:17:38 PM »
Thanks for the tip... i didn´t knew that technique!
Your example was a bit confusing though, but i figured it out. In case somebody else stumbles upon this question, i´ll repost the more straight forward answer, wich works for me:

  1.    
  2. for (int i = 0; i < someList.Length; ++i) // <-- replace with whatever container you're using
  3.     {
  4.         UIEventListener.Get(someList[i]).onTooltip = delegate (GameObject g, bool show)
  5.         {
  6.             MyCallbackMethod(gm show, i)
  7.         });
  8.     }
  9.  
  10. public void MyCallbackMethod(GameObject g, bool show, int index)
  11.     {
  12.         Debug.Log("Tooltip on " + g.name + ", index " + index + ": " + show);  
  13.     }
  14.  

15
NGUI 3 Support / Re: Add onTooltip to UIEventTrigger
« on: February 05, 2016, 06:27:07 AM »
Ok, now i´m confused and i´m not sure i´m understanding the diffrent Methods of using NGUI events and their subscruption. Let me try to restate, how i understand things at the moment:

- every Element wich has a collider/rigidbody and is on the EventMask Layer gets the events from the camera, like onHover or onClick. You can listen to these events, using void OnHover() method in a component on those gameobjects. Since i´m using a UIManager class i´m NOT utilising this.

- since i have 2D UI Elements combined with interactive elements in the 3D world, i use the UICameraScript on the UICamera (EventMask = 2D UI stuff) and the WorldCamera (EventMask = interactive 3D elements).

- by subscribing directly to the UICamera events in my UIManager, i get those events and can use my own callbacks to process the events. All i need is a callback method wich recieves the same arguments as get passed by the event. Every interactive Element will call the event and it´s NOT possible to add custom callsbacks with custom parameters.

- if i need to pass custom arguments to events, i used the UIEventTrigger, since it allows me to setup an EventDelegate like so:
  1. EventDelegate ed = new EventDelegate(this, "GetHoverIndex");
  2. ed.parameters[0].value = 0;
  3. EventDelegate.Set(staticBuild.transform.FindChild("BuildTower1").GetComponent<UIEventTrigger>().onHoverOver, ed);
  4.  
This method needs the EventTrigger component attached to each interactive element, even if i´m using code to subscribe like above.

- The UIEventlistener works like the subscription to UICamera events, only that i can subscribe specific callbacks to specific elements like so:
  1. UIEventListener.Get(staticBuild.transform.FindChild("BuildTower1").gameObject).onTooltip += TestToolTip;
So the advantage is, that i only get callbacks from the elements i want AND i can route them to diffrent callbacks, event they get triggered by the same even. I have not found a way to subscribe an EventDelegate to this though.

So what i want to do is have tooltips on several elments. the tooltip content differes based on the elements for sure. my plan was to give each element an id and have the content found based on the ID. So what i did was,  i used the onHover Event from the Trigger as in the example above to get the hovered button ID and stored it. Then i subscribed to the UICamera.onTooltip Event. When this event was called, i used the stored ID to get the right content in place and showed the tooltip.

I´m not 100% sure how to do something similar with the EventListener. The only thing i can think of is to have for each element a custom callback wich carrys the content (or the ID to call the content).


So is there a way to add additional parameters to UICamera or EventListener events? or even completely customize the EventDelegate like with the EventTrigger?

Pages: [1] 2