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

Pages: [1]
1
NGUI 3 Support / Re: Advanced Anchors at runtime
« on: June 21, 2014, 04:00:01 AM »
Thank you. I love your work btw. Making my life so much easier.

2
NGUI 3 Support / Re: UIEventTrigger access
« on: June 21, 2014, 03:57:45 AM »
Ahh, yes. Thank you. But for parameters, you have set it up to use
  1. myDelegate.parameters.SetValue (a, 0);
correct?

because i couldn't get
  1. eventDelegate.parameters = new EventDelegate.Parameter[] { ... };
to work for the life of me. With it being read only.

3
NGUI 3 Support / Re: UIEventTrigger access
« on: June 19, 2014, 06:00:03 AM »
Figured it out I think. Something like this looks like it's working...

  1. EventDelegate myDelegate = new EventDelegate();
  2.  
  3. ...
  4.  
  5. EventDelegate.Parameter a = new EventDelegate.Parameter();
  6. a.obj = myComponent.gameObject;
  7. myDelegate.Set( this, "myFunction");
  8. myDelegate.parameters.SetValue (a, 0);
  9. myComponent.gameObject.AddComponent<UIEventTrigger> ();
  10. myComponent.gameObject.GetComponent<UIEventTrigger> ().onClick.Add (myDelegate);

4
NGUI 3 Support / Re: UIEventTrigger access
« on: June 19, 2014, 05:12:15 AM »
The parameters you'd specify. It's up to you to specify eventDelegate.parameters = new EventDelegate.Parameter[] { ... };.

eventDelegate.parameters is read only. So how can we assign anything to it during runtime? Am I missing something here?

5
NGUI 3 Support / Re: Advanced Anchors at runtime
« on: June 18, 2014, 06:10:45 PM »
copy. So use 8 lines of code for all four sides, plus the resetAnchor and UpdateAnchor calls instead of a beast of a function call. Was that anywhere in your tutorials? Sorry if it was, I looked for hours. Thanks for the reply.

6
NGUI 3 Support / Re: Advanced Anchors at runtime
« on: June 18, 2014, 04:33:32 PM »
Well I just realized, if it's advanced, I will need to set the relatives as well. sorry for the confusion. Is this the correct way?

/// <summary>
   /// Anchor this rectangle to the specified transform using the advanced system. Relative values are a scale from 0 to 1, 0 being left/bottom, 1 being right/top.
   /// </summary>
   
   public void SetAnchor (GameObject leftGO, int leftA, float leftR, GameObject bottomGO, int bottomA, float bottomR,
                          GameObject rightGO, int rightA, float rightR, GameObject topGO, int topA, float topR)
   {
      Transform tl = (leftGO != null) ? leftGO.transform : null;
      Transform tr = (rightGO != null) ? rightGO.transform : null;
      Transform tt = (topGO != null) ? topGO.transform : null;
      Transform tb = (bottomGO != null) ? bottomGO.transform : null;
      
      leftAnchor.target = tl;
      rightAnchor.target = tr;
      topAnchor.target = tt;
      bottomAnchor.target = tb;
      
      leftAnchor.relative = leftR ;
      rightAnchor.relative = rightR ;
      bottomAnchor.relative = bottomR ;
      topAnchor.relative = topR ;
      
      leftAnchor.absolute = leftA;
      rightAnchor.absolute = rightA;
      bottomAnchor.absolute = bottomA;
      topAnchor.absolute = topA;
      
      ResetAnchors();
      UpdateAnchors();
   }

7
NGUI 3 Support / Advanced Anchors at runtime
« on: June 18, 2014, 04:19:07 PM »
I haven't been able to find anything on setting advanced anchors at runtime. SetAnchor seems to only setup a unified anchor. I added an overload to fix this. If it is the correct way, could we get it added to the next update?

        /// <summary>
   /// Anchor this rectangle to the specified transform using an advanced anchor system.
   /// </summary>
   
   public void SetAnchor (GameObject leftGO, int left, GameObject bottomGO, int bottom, GameObject rightGO, int right, GameObject topGO, int top)
   {
      Transform tl = (leftGO != null) ? leftGO.transform : null;
      Transform tr = (rightGO != null) ? rightGO.transform : null;
      Transform tt = (topGO != null) ? topGO.transform : null;
      Transform tb = (bottomGO != null) ? bottomGO.transform : null;
      
      leftAnchor.target = tl;
      rightAnchor.target = tr;
      topAnchor.target = tt;
      bottomAnchor.target = tb;
      
      leftAnchor.relative = 0f;
      rightAnchor.relative = 1f;
      bottomAnchor.relative = 0f;
      topAnchor.relative = 1f;
      
      leftAnchor.absolute = left;
      rightAnchor.absolute = right;
      bottomAnchor.absolute = bottom;
      topAnchor.absolute = top;
      
      ResetAnchors();
      UpdateAnchors();
   }

Pages: [1]