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

Pages: [1] 2
1
All fixed, thanks ArenMook, the fix was appreciated!

2
Cool, will give it a shot in the morning, thanks!

3
You wanted me to bring this to your attention once we were past the 16th. Hope you had a nice vacation!

4
Sure thing, in the meanwhile enjoy the sand and sun.

5
I hope your having a good time! As for the duration, I can see during runtime that the duration is indeed not set to zero.

6
Setting the EventDelegate.Add to true worked and only ran my method once. I did run into one more issue, I made TestMe() make a call back against Fade(), but this time with a new EvenDelegate parameter which points at Last(). For the rest of my testing I am only creating the TweenAlpha at runtime. Things are almost working, the issue is that after the first call to Fade() finished, I get notification of TestMe() having been run, and the call to Fade() works functionally correct, except the new EventDelegate that we are using on our .onFinished fires off immediately, instead of truly waiting for the fade to finish playing ( it is still fading up to our new 1.0f value and I watch the runtime TweenAlpha playing out correctly ( even though the EventDelegate pointing at Last() gets called prematurely ). Visually, the 2 calls to Fade() look like they are working visually, just the premature call to the second EventDelegate is confusing. Am I missing something, why would the new EventDelegate which we added to .onFinished fire off without the Tween actually having finished?

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ActivePlayerHUDController : MonoBehaviour {
  5.  
  6.     #region // Member Variable Declaration
  7.     public UILabel cardLabel;
  8.     public UISprite card1;
  9.     public UISprite card2;
  10.     public UISprite card3;
  11.     public UISprite card4;
  12.     public UISprite card5;
  13.  
  14.     private TweenAlpha activePlayerHUDAlpha;
  15.     private bool isVisible;
  16.     #endregion
  17.  
  18.     void Start() {
  19.         Fade(1.0f, 0.2f, 3.0f, new EventDelegate(TestMe));
  20.     }
  21.  
  22.     void Fade(float fromValue, float toValue, float duration, EventDelegate method) {
  23.         TweenAlpha tween = TweenAlpha.Begin(gameObject, duration, toValue);
  24.         if(method != null) {
  25.             EventDelegate.Add(tween.onFinished, test, true);
  26.         }
  27.         tween.from = fromValue;
  28.         tween.style = UITweener.Style.Once;
  29.         tween.animationCurve = new AnimationCurve(
  30.             new Keyframe(0.0f, 0.0f, 1.0f, 1.0f),
  31.             new Keyframe(1.0f, 1.0f, 1.0f, 1.0f));
  32.     }
  33.    
  34.     void TestMe() {
  35.         Debug.Log("Fade called me");
  36.         Fade(0.2f, 1.0f, 5.0f, new EventDelegate(Last));
  37.     }
  38.  
  39.     void Last() {
  40.         Debug.Log("Last call!");
  41.     }
  42. }
  43.  
  44.  

7
I tend to find the UI for editing the Animation Curve supplied in the TweenAlpha component to be lackluster, especially in regards to accuracy, for example lacking numerical input editing of the keys, hence why I may resort to using code in conjunction with a pre-existing TweenAlpha.  No sure if that UI is just supplied natively by Unity. As for mixing a TweenAlpha component with also trying to edit it via code seems completely reasonable to do, though I can see reasoning to go and use only one or the other. Thanks for the info on the listener, will modify my code once I am back at my computer.

8
Thanks for the reply, and yes this code is decently old, and was working in an older version of NGUI. I am happy to move towards the newer ways of doing things. I have been able to stop crashing due to the changes I made to my code, but I am not getting a repeating call to my EventDelegate, and I am unsure why that would be the case, as I am calling Fade() again from the method the EventDelegate was pointing to, but with a null the second time around instead of the EventDelegate that the original Fade() was using.

I am also curious if I am approaching this the right way now. I do have a pre-existing TweenAlpha and I still make reference to it, and set values against it. As I am changing those values on the line after the TweenAlpha.Begin() line, are they actually going to be set in time for the first firing of Begin? ( my guess is yes as we are still on the same frame that Begin was called on. If there is still something incorrect to my approach in regards to the latest NGUI please let me know. Thanks!

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ActivePlayerHUDController : MonoBehaviour {
  5.     #region // Member Variable Declaration
  6.     public UILabel cardLabel;
  7.     public UISprite card1;
  8.     public UISprite card2;
  9.     public UISprite card3;
  10.     public UISprite card4;
  11.     public UISprite card5;
  12.  
  13.     private TweenAlpha activePlayerHUDAlpha;
  14.     private bool isVisible;
  15.     #endregion
  16.  
  17.     void Start() {
  18.          activePlayerHUDAlpha = this.GetComponent<TweenAlpha>();
  19.          EventDelegate testDelegate = new EventDelegate(TestMe);
  20.          Fade(activePlayerHUDAlpha, 1.0f, 0.2f, 3.0f, testDelegate);
  21.          //Fade(activePlayerHUDAlpha, 1.0f, 0.2f, 3.0f, null);
  22.     }
  23.  
  24.      void Fade(TweenAlpha alpha, float fromValue, float toValue, float duration, EventDelegate test) {
  25.          TweenAlpha.Begin(gameObject, duration, toValue).onFinished.Add(test);
  26.          alpha.from = fromValue;
  27.          alpha.style = UITweener.Style.Once;
  28.          alpha.animationCurve = new AnimationCurve(
  29.                   new Keyframe(0.0f, 0.0f, 1.0f, 1.0f),
  30.                   new Keyframe(1.0f, 1.0f, 1.0f, 1.0f));
  31.         }
  32.    
  33.      void TestMe() {
  34.          Debug.Log("Fade called me");
  35.          Fade(activePlayerHUDAlpha, 0.2f, 1.0f, 3.0f, null);
  36.     }
  37. }
  38.  

9
Crashing Unity when calling a method that uses TweenAlpha

I am including my example script, I am unsure why this would cause Unity to hard crash.
If I take out the call to Fade from within TestMe() Unity is fine, if I have the call in as shown above, it hard crashes Unity.

I am hoping I am doing something wrong, but it not, I figured you may want to know about it.

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ActivePlayerHUDController : MonoBehaviour {
  5.  
  6.     public UILabel cardLabel;
  7.     public UISprite card1;
  8.     public UISprite card2;
  9.     public UISprite card3;
  10.     public UISprite card4;
  11.     public UISprite card5;
  12.  
  13.     private TweenAlpha activePlayerHUDAlpha;
  14.     private bool isVisible;
  15.  
  16.     void Start() {
  17.         activePlayerHUDAlpha = this.GetComponent<TweenAlpha>();
  18.         Fade(activePlayerHUDAlpha, 0.0f, 1.0f, 10.0f, "TestMe");
  19.     }
  20.  
  21.     void Update() {  
  22.     }
  23.  
  24.     void Fade(TweenAlpha alpha, float fromValue, float toValue, float duration, string methodAsString) {
  25.         alpha.from = fromValue;
  26.         alpha.to = toValue;
  27.         alpha.duration = duration;
  28.         if (methodAsString != "") {
  29.             alpha.callWhenFinished = methodAsString;
  30.         }
  31.         alpha.style = UITweener.Style.Once;
  32.         alpha.eventReceiver = gameObject;
  33.         alpha.animationCurve = new AnimationCurve(
  34.             new Keyframe(0.0f, 0.0f, 1.0f, 1.0f),
  35.             new Keyframe(1.0f, 1.0f, 1.0f, 1.0f));
  36.         alpha.Play(true);
  37.     }
  38.  
  39.     void TestMe() {
  40.         Fade(activePlayerHUDAlpha, 1.0f, 0.0f, 3.0f, "");
  41.     }
  42. }
  43.  
  44.  

10
Ok so if I need my fonts to be rendered via point filtering, then I should stick with my bitmap workflow? Easy enough for my needs, just wanted to make sure what I was seeing was indeed the case. Thanks for the clarification!

11
Just for clarification, when I searched on this topic, I had noticed that a number of other people had mentioned it as a side not in other threads, but nothing came of it. I figured I would make a thread dedicated to this now.

12
Dynamic Font - Font Texture unable to set Filter Mode ( Greyed Out )

I wanted to try to start using Dynamic fonts within my project, so I moved my various TTFs into my project and I created a UILabel using one of my TTF, I found that underneath my TTF I can now see a Font Material and a Font Texture. I then noticed that the resulting Dynamic TTF Font Texture has all of it's controls greyed out / locked. I sure would like to set it the Filter Mode to Point.

The TTF I am using looks tons better ( not fuzzy or blurry ) when I use it as a bitmapped font via an external program ( of course then setting the atlas that I was using to filter mode: point ). Any thoughts?

I am currently on V 3.0.5 and Unity 4.3 ( though I had tried this under Unity 4.2 as well ), thanks in advance!

13
NGUI 3 Support / Re: BUG - UITweens
« on: April 16, 2013, 11:58:57 PM »
Ok so I was able to work past my issue, I would love to see this get fixed in a release by the author. Thanks again CBartlett.

14
NGUI 3 Support / Re: BUG - UITweens
« on: April 15, 2013, 04:34:04 PM »
Good point, I should probably switch over to using my own anim curve, and just let it play forward forever ( loop mode ), but to do it perfectly, unless his loop code already knows how to handle the anim curve properly, you would end up with 2 time slices with the same data ( first key, last key values ) that could cause a pause, my hope is that it is already being handled. Either way I can work past my issue.

I do have a question, I am doing a .Reset() in my code before doing a .Play() it seems like it is required for what I am trying to do ( change values of the TweenAlpha and play that new data ), but I wanted to make sure it was strictly required. Thanks again!

15
NGUI 3 Support / Re: BUG - UITweens
« on: April 14, 2013, 10:40:18 PM »
I think I may have a similar or possible same bug as you guys:

What I am trying to do:
I have a simple setup, a label that has a simple TweenAlpha on it. The base settings are setup so it will pingpong between 1 to 0, essentially blinking the label on and off smoothly over the course of 1 second. When I hit a certain key, I want it to take it's current value and set the TweenAlpha up so that it goes from current alpha value back to 1 over the course of a certain amount of time. For example possibly over 4 seconds ( this was just for testing ).

What happens:
It seems to be failing on the reverse trip of TweenAlpha, if I run FinalAlpha() during the forward direction of the TweenAlpha, it fires off perfectly, if I ask it to run FinalAlpha() during the reverse direction of the TweenAlpha, it immediately completes my new settings in 0 seconds. I had tried to detect which direction the TweenAlpha was going when I wanted to run FinalAlpha(), but no matter if I did, and tried to .Toggle() the TweenAlpha or not, I can't get the behavior to work when the TweenAlpha was in the middle of the reverse direction when I called FinalAlpha(). Any ideas??

I am using the following code:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PressStart : MonoBehaviour {
  5.  
  6.     private UILabel label;
  7.     private TweenAlpha alpha;
  8.     private bool startPressed = false;
  9.     private bool ranFinalAlpha = false;
  10.     private float startTime = 0.0f;
  11.     private float endTime = 0.0f;
  12.  
  13.     // Use this for initialization
  14.     void Start() {
  15.         label = gameObject.GetComponent<UILabel>();
  16.         alpha = gameObject.GetComponent<TweenAlpha>();
  17.         Debug.Log(string.Format("Label: {0}", label.name));
  18.         Debug.Log(string.Format("ColorTint: {0}", label.color));
  19.         scale.Reset();
  20.     }
  21.  
  22.     // Update is called once per frame
  23.     void Update() {
  24.         if (Input.GetButton("Win 360 Pad1 Start") && !startPressed) {
  25.             startPressed = true;
  26.             Debug.Log("Pressed Start button");
  27.         }
  28.  
  29.         if (startPressed) {
  30.             if (!ranFinalAlpha) {
  31.                 FinalAlpha();
  32.             }
  33.         }
  34.     }
  35.  
  36.     void FinalAlpha() {    
  37.         startTime = Time.time;
  38.         ranFinalAlpha = true;
  39.         Debug.Log("Entered final alpha");
  40.         float currentAlpha = alpha.alpha;
  41.         Debug.Log(string.Format("Alpha when called: {0}", currentAlpha));
  42.         alpha.from = currentAlpha;
  43.         alpha.to = 1.0f;
  44.         alpha.duration = 4.0f;
  45.         alpha.style = UITweener.Style.Once;
  46.         alpha.callWhenFinished = "CalledToFinish";
  47.         alpha.eventReceiver = gameObject;
  48.  
  49.         alpha.Reset();
  50.  
  51.         alpha.Play(true);
  52.     }
  53.  
  54.     void CalledToFinish() {
  55.         endTime = Time.time;
  56.         Debug.Log("Was called at finish!");
  57.         Debug.Log(string.Format("Elapsed Time: {0}", endTime - startTime));
  58.     }
  59.  
  60.     void OnGUI() {
  61.         GUILayout.BeginArea(new Rect(0, 0, 330, 700));
  62.         GUILayout.Label(string.Format("Current Alpha: {0}", alpha.alpha));
  63.         GUILayout.EndArea();
  64.     }
  65. }
  66.  

Pages: [1] 2