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 - maxdev

Pages: [1]
1
Hey, any input on this? Thanks.

2
Hello,

I am implementing a powerup menu that that has icons pop out and close after the player clicks a powerup.
My issue is I want the powerup menu's icons to reset to their hidden positions after the panel holding the menu is set to inactive.
So I figured the resetIfDisabled should do just that, so I call that in the start function on the power menu script.

This is how my hierarchy is set up:

--PowerupPanel
----PowerupMenu <-- Has following script attached, a collider and a UIPlayTween(Play Direction is set to Toggle) for each Powerup.
--------PowerupA - Has Tween Position to pop the powerup out.
--------PowerupB - Has Tween Position to pop the powerup out.
--------PowerupC - Has Tween Position to pop the powerup out.

The script I have attached to the PowerupMenu:

  1. void Start () {
  2.         foreach (UIPlayTween ptt in gameObject.GetComponents<UIPlayTween>())
  3.         {
  4.             ptt.resetIfDisabled = true;
  5.         }
  6.  
  7.         foreach(UIPlayTween pt in transform.GetComponentsInChildren<UIPlayTween>(true))
  8.         {
  9.             pt.resetIfDisabled = true;
  10.         }      
  11.         }
  12.  

What happens is the powerup menu works but when I hide and unhide the panel the state they
are in stays, meaning they dont return to their original hidden positions.

Any help or insight would be very appreciated!

Thanks,
Max

3
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: June 22, 2014, 08:47:41 PM »
Thanks very very much trenrod, it works perfectly!

4
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: June 21, 2014, 04:21:44 PM »
  1. IEnumerator SpawnCalc()
  2. {
  3. GameObject insc = Instantiate(prefab, transform.position, Quaternion.identity) as GameObject;
  4. insc.GetComponent<TweenPosition>().enabled = true;
  5.  
  6.         EventDelegate.Parameter a = new EventDelegate.Parameter();
  7.         a.obj = insc;
  8.         a.field = "test";
  9.  
  10.         EventDelegate del = new EventDelegate(this.testyay);
  11.         EventDelegate.Add(insc.GetComponent<TweenPosition>().onFinished, del);
  12.  
  13.         del.parameters.SetValue(a, 0);
  14. }
  15.  

  1. private void testyay(EventDelegate.Parameter f)
  2. {
  3. print(f.obj.name);
  4. }
  5.  

Why doesnt this work? I'd very much appreciate a working example since it seems to me like I've tried
every combination I can think of or find and it still doesnt work...

5
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: June 21, 2014, 03:34:46 PM »
Also I am getting a null ref on this line:

  1. del.parameters.SetValue(insc, 0);
  2.  

6
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: June 21, 2014, 02:14:45 PM »
If I write this, it works. However how can I read insc variable in testyay function?
  1. IEnumerator SpawnCalc()
  2.         {
  3. GameObject insc = Instantiate(prefab, transform.position, Quaternion.identity) as GameObject;
  4.  
  5. EventDelegate del = new EventDelegate(this.testyay);
  6. EventDelegate.Add(insc.GetComponent<TweenPosition>().onFinished, del);
  7.  
  8. del.parameters.SetValue(insc, 0);
  9. }
  10.  

  1. public void testyay() {
  2. print(insc.name);
  3. }
  4.  

Thanks!

7
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: June 21, 2014, 12:44:45 AM »
Hey guys, I for the life of me cant get this to work, partially because I have yet
to fully understand delegates and also due to some lack of examples for this case.

  1. EventDelegate.Parameter a = new EventDelegate.Parameter();
  2. a.obj = insc;
  3. a.field = "test";
  4.  
  5. EventDelegate.Parameter b = new EventDelegate.Parameter();
  6. b.obj = insc;
  7. b.field = "anotherField";
  8.  
  9. EventDelegate del = new EventDelegate(this.testyay);
  10. EventDelegate.Add(insc.GetComponent<TweenPosition>().onFinished, del);
  11.  
  12. del.parameters = new Parameter[] { a, b };
  13.  

  1. public void testyay() {
  2.         // get my gameobject insc
  3. }
  4.  

I get several errors:
Quote
error CS0246: The type or namespace name `Parameter' could not be found. Are you missing a using directive or an assembly reference?
Quote
Property or indexer `EventDelegate.parameters' cannot be assigned to (it is read only)

How can I get insc object in testyay function?

Thanks in advance!

8
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: April 21, 2014, 04:18:26 PM »
I tried several things to solve this and even watched a tutorial by Aren about this, but have yet
to find a way to do it purely though code. Any ideas will be appreciated.

9
NGUI 3 Support / Passing Instance References Via EventDelegate
« on: April 17, 2014, 12:30:23 PM »
Hey guys,

I am making a combo system that gets an array of positions and spawns sprites.
I then move these sprites to the score on the top left of the screen via TweenPosition. When they reach the end of the tween, I'd like to run a function and pass the object that finished to it.

This is basically what works, however, I have no idea how to pass the gameobject(insc) to that function:
EventDelegate.Add(insc.GetComponent<TweenPosition>().onFinished, AddToScore);

I'd definitely love some input on this as I tried reading the docs and only found a way
to read parameters but not write.

Thanks very much!
Max

10
NGUI 3 Support / Re: Having UILabel Follow Object in Scene
« on: April 17, 2014, 11:38:36 AM »
Thanks a bunch Aren, that did the trick. I am wondering though, as I am using this for a combo system and at times on several objects per frame, is it too resource intensive for mobiles? Is there
a more recommended method?

Thanks!

11
NGUI 3 Support / Re: Having UILabel Follow Object in Scene
« on: April 12, 2014, 07:06:41 AM »
Hey Aren. Thanks for your helpful reply.

What I would really like to do is have a UILabal spawn on a world space object and in the camera
space move to the score one the bottom right, as in this image. What I tried to do is
set the from position by taking the vector 3 of the world space object and transforming it
into screen space and viewport space but to no avail. Any ideas on how I could accomplish this?



Thanks a bunch!

12
NGUI 3 Support / Having UILabel Follow Object in Scene
« on: April 11, 2014, 11:06:38 PM »
Hey guys,

I am trying to have a UILabal move and essentially follow an object in the scene.
I tried doing WorldSpaceToViewport and ToScreen on NGUI's camera and moving the object with MoveTowards. But the results are that it shoots off to the side and isnt sitting on top of the object. The only way I found is to disable NGUI's camera and use my regular Main Camera, but this seems moot.

Any suggestions will be very appreciated!

Thanks!

Pages: [1]