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.


Topics - schellenberghq

Pages: [1] 2
1
Error from console:

Assets/NGUI/Scripts/Internal/EventDelegate.cs(485,81): error CS0246: The type or namespace name `ExecuteInEditModeAttribute' could not be found. Are you missing a using directive or an assembly reference?

Apparently in Unity 5.0.0b17 ExecuteInEditModeAttribute breaks.

2
NGUI 3 Support / Tab navigation works in editor but not browser.
« on: October 22, 2014, 10:02:41 AM »
I've created my own tabIndex type navigation.

For some reason though, in the Unity editor pressing tab works just fine, even when a UIInput is the current selected object. However once I build for web and try it in the browser, suddenly my tabs stop working. However if I add a KeyNavigation script from NGUI it kind of works better.

Is NGUI doing something cancel my Tab presses because the UI element doesn't have a KeyNavigation script? It's just odd that it doesn't matter because it works in the editor, but not in the browser.

Any ideas?

3
NGUI 3 Support / Assigning Delegates via Inspector vs Code
« on: October 21, 2014, 12:01:57 PM »
Question:

Do you prefer assigning event delegates using the Inspector or via Code.

I ask this because when I first started my project, I assigned all the events via inspector.
As the project progressed, I found I needed to assign some events via code because they came dynamically.
And now, I find myself wanting to go back and assign via code all the events I am currently doing via Inspector.
I came to this conclusion because I decided it was much easier to maintain and fix/alter these events via code than it was via inspector.
For example, if I replace my Create Button, I now have to reassign the event in it's OnClick, and if it has multiple events than it's spending a few minutes rewiring all those events back up.
However, if the events were assigned via code, I would simple have to reassign the new Create Button to my script via the Inspector.

I guess it's about consistency. I'm just realizing that I consistently assign UI elements via inspector, as opposed to trying to use FindGameObject like I used to along time ago.

Perhaps it is also about how much control you want or need.

Anyways, just some thoughts.


  1. // Example of assigning event via code. In this scenario I would say it's the same as assigning in the inspector, and may actually cause unwanted behavior if you change the method name.
  2. createButton.onClick.Add (new EventDelegate (this, "OnCreate"));
  3.  
  4. void OnCreate(){
  5.  // create something
  6. }

This feels more maintainable to me than having to manually assign events via inspector.
  1. // However assigning events like this removes the misspelled string, as now you have to strongly use the actual method
  2. // Setup button events
  3. createButton.onClick.Add(new EventDelegate(OnCreate));
  4. editButton.onClick.Add (new EventDelegate (OnEdit));
  5. exportViewButton.onClick.Add (new EventDelegate (OnExport));
  6. helpButton.onClick.Add (new EventDelegate (OnHelp));
  7. doneButton.onClick.Add (new EventDelegate (OnDone));
  8.  

And even further, adding events with parameters.

  1. // Sample Event Delegate with parameter: EventDelegate.Set(btn.onClick, delegate() { MyClick(123); });
  2. EventDelegate.Set (newCanvasViewController.canvasOverviewButton.onClick, delegate() {
  3.         OnClickedCanvasOverview (newCanvasViewController);
  4. });
  5.  
  6. EventDelegate.Set (newCanvasViewController.deleteButton.onClick, delegate() {
  7.         OnDelete (newCanvasViewController);
  8. });
  9.  
  10. EventDelegate.Set (newCanvasViewController.createButton.onClick, delegate() {
  11.         OnFinishCreate (newCanvasViewController);
  12. });
  13.  
  14. EventDelegate.Set (newCanvasViewController.titleOfCanvasInput.onSubmit, delegate() {
  15.         OnDone();
  16. });
  17.  
I am in no way diminishing the importance and awesome-ness, and ease of assigning events via Inspector. I'm simply speculating as a programmer.

4
NGUI 3 Support / SetDirty(this)
« on: January 16, 2014, 01:04:16 PM »
This line, UnityEditor.EditorUtility.SetDirty(this) is being called from some UILabel object, but I have no idea which one, so I can't tell which UILabel is missing.

This happens when I LoadLevel.AsyncAdditive. Essentially I'm async/additive a scene, and than delete the root of the previous scene.

If I comment out the SetDirty(this) line, things go smoothly and no errors. However, I'm sure that line is there for a reason.
Instead of commenting it out, should I just add a null check?

The Error Message:
  1. MissingReferenceException: The object of type 'UILabel' has been destroyed but you are still trying to access it.
  2. Your script should either check if it is null or you should not destroy the object.
  3. UIWidget.MarkAsChanged () (at Assets/NGUI/Examples/Scripts/Internal/UIWidget.cs:552)
  4. UILabel.MarkAsChanged () (at Assets/NGUI/Examples/Scripts/UI/UILabel.cs:900)
  5. UnityEngine.Font.InvokeFontTextureRebuildCallback_Internal ()
  6. UnityEngine.Font:RequestCharactersInTexture(String, Int32, FontStyle)
  7. NGUIText:WrapText(Font, String, String&) (at Assets/NGUI/Examples/Scripts/Internal/NGUIText.cs:357)
  8. UILabel:ProcessText(Boolean) (at Assets/NGUI/Examples/Scripts/UI/UILabel.cs:950)
  9. UILabel:ProcessText() (at Assets/NGUI/Examples/Scripts/UI/UILabel.cs:907)
  10. UILabel:ProcessAndRequest() (at Assets/NGUI/Examples/Scripts/UI/UILabel.cs:423)
  11. UILabel:set_trueTypeFont(Font) (at Assets/NGUI/Examples/Scripts/UI/UILabel.cs:191)
  12. UILabel:OnValidate() (at Assets/NGUI/Examples/Scripts/UI/UILabel.cs:449)
  13.  

The Line comes from UIWidget:
  1. public virtual void MarkAsChanged ()
  2.         {
  3.                 mChanged = true;
  4. #if UNITY_EDITOR
  5.                                 UnityEditor.EditorUtility.SetDirty(this);
  6. #endif

5
NGUI 3 Support / Sliced Sprite issues with atlas reference swap
« on: November 14, 2013, 04:20:26 PM »
In my project the expected behavior is correct on Simple Sprites.
The expected behavior when switching between low/hi def atlas is that a) the sprite uses the same real estate, b) the sprite looks low/hi quality.

The issue is with sliced sprites. In the provided images, I have 2 button sprites. One exported at 160dpi, and the other at 320dpi. The result is smaller pixel size, thus less memory and texture space.

I have ensured that both sprites have the same slicing.

The 320dpi button looks perfect. However the 160dpi sprite takes up more real estate than expected and becomes deformed. Rather than the expected behavior of looking lower quality.

Is this the expected behavior for sliced sprites?

I have considered Not using a sliced sprite, which would indeed fix the issue, but there are many areas in the project in which a sliced sprite would be much more efficient over full size exports.

Thoughts/recommendations?

Thanks!

EDIT: I just realized that you may not be able to fully see the size differences with the provided button screenshots because you can't see the full context of the scene. Unfortunately due to the projects NDA, I may run into problems revealing more.

6
NGUI 3 Support / Fate of NGUI after uGUI
« on: November 13, 2013, 04:22:11 PM »
What is the fate of NGUI after uGUI releases?
NGUI and uGUI are very similar because it's from the same developer, but will there be drastic enough differences to choose one over the other?
Or is it more like those using NGUI will continue to use it in current projects, but in new projects switch to uGUI.

7
NGUI 3 Support / Atlas Reference breaks when adjusting slice
« on: November 13, 2013, 04:03:09 PM »
Hey, I'm using a hi/low def atlas with a reference. I ensure that all my sprites are using the reference. The problem is, if I adjust the slicing of a sprite, the reference breaks and any sprites with the adjusted slice now only refers to the non-reference atlas.

For example, if I have a button with a Background sprite, and its atlas is GUI_Atlas_Reference and that currently points to GUI_Atlas_160, if I adjust the slicing in the GUI_Atlas_160, the background sprite no longer points to GUI_Atlas_Reference, it now points to the last atlas the reference was pointing at, which in this case would be GUI_Atlas_160.

The problem is, because the 2 atlases may require difference slicing for the same sprite, I try to get them close, but I have to keep going back to my gameObject sprite and reattach the GUI_Atlas_Reference.

I could get through this by just ensuring all my slices are done right in the first place, but sometimes it's difficult to adjust the slicing correctly without seeing the end result in the scene.

perhaps this could be resolved in NGUI?

Thanks!

8
NGUI 3 Support / Colliders automatically reset
« on: October 24, 2013, 11:44:54 AM »
I keep having this odd issue with Colliders. I'm not sure if it's from NGUI or Unity.

Essentially, I'd adjust my colliders for certain UI elements, not in play mode, and they seem to stick for a while, but randomly it seems they readjust as if I had did alt+shft+c to add a collider.

Is there something that causes colliders to auto readjust? How can I prevent this from happening?

-Jacob S.

9
NGUI 3 Support / Request: Set Selection Depth to 0
« on: September 30, 2013, 02:58:44 PM »
First off, the updated depth system is working perfect for me. Thank you.
My one request is to have the option in NGUI menu to set all the selected widgets Depth to 0. This way I can decide for myself the depths of each widget, but setting them to 0 initially gives me a starting point.

Thanks!

10
NGUI 3 Support / UICheckboxPlus (UITexture instead of UISprite)
« on: September 09, 2013, 03:53:09 PM »
I modified the code of the UICheckbox to handle a UITexture instead of a UISprite. This came in handy for me, so I figure perhaps there is someone else out there who could benefit from it. So here you are.


  1. //----------------------------------------------
  2. //            NGUI: Next-Gen UI kit
  3. // Copyright © 2011-2013 Tasharen Entertainment
  4. //----------------------------------------------
  5.  
  6. using UnityEngine;
  7. using AnimationOrTween;
  8.  
  9. /// <summary>
  10. /// Simple checkbox functionality. If 'option' is enabled, checking this checkbox will uncheck all other checkboxes with the same parent.
  11. /// </summary>
  12.  
  13. [AddComponentMenu("NGUI/Interaction/Checkbox")]
  14. public class UICheckboxPlus : MonoBehaviour
  15. {
  16.         static public UICheckboxPlus current;
  17.         public delegate void OnStateChange (bool state);
  18.  
  19.         /// <summary>
  20.         /// Sprite that's visible when the 'isChecked' status is 'true'.
  21.         /// </summary>
  22.  
  23.         public UITexture checkSprite;
  24.  
  25.         /// <summary>
  26.         /// Animation to play on the checkmark sprite, if any.
  27.         /// </summary>
  28.  
  29.         public Animation checkAnimation;
  30.  
  31.         /// <summary>
  32.         /// If checked, tween-based transition will be instant instead.
  33.         /// </summary>
  34.  
  35.         public bool instantTween = false;
  36.  
  37.         /// <summary>
  38.         /// Whether the checkbox starts checked.
  39.         /// </summary>
  40.  
  41.         public bool startsChecked = true;
  42.  
  43.         /// <summary>
  44.         /// If the checkbox is part of a radio button group, specify the root object to use that all checkboxes are parented to.
  45.         /// </summary>
  46.  
  47.         public Transform radioButtonRoot;
  48.  
  49.         /// <summary>
  50.         /// Can the radio button option be 'none'?
  51.         /// </summary>
  52.  
  53.         public bool optionCanBeNone = false;
  54.  
  55.         /// <summary>
  56.         /// Generic event receiver that will be notified when the state changes.
  57.         /// </summary>
  58.  
  59.         public GameObject eventReceiver;
  60.  
  61.         /// <summary>
  62.         /// Function that will be called on the event receiver when the state changes.
  63.         /// </summary>
  64.  
  65.         public string functionName = "OnActivate";
  66.  
  67.         /// <summary>
  68.         /// Delegate that will be called when the checkbox's state changes. Faster than using 'eventReceiver'.
  69.         /// </summary>
  70.  
  71.         public OnStateChange onStateChange;
  72.  
  73.         // Prior to 1.90 'option' was used to toggle the radio button group functionality
  74.         [HideInInspector][SerializeField] bool option = false;
  75.  
  76.         bool mChecked = true;
  77.         bool mStarted = false;
  78.         Transform mTrans;
  79.  
  80.         /// <summary>
  81.         /// Whether the checkbox is checked.
  82.         /// </summary>
  83.  
  84.         public bool isChecked
  85.         {
  86.                 get { return mChecked; }
  87.                 set { if (radioButtonRoot == null || value || optionCanBeNone || !mStarted) Set(value); }
  88.         }
  89.  
  90.         /// <summary>
  91.         /// Legacy functionality support -- set the radio button root if the 'option' value was 'true'.
  92.         /// </summary>
  93.  
  94.         void Awake ()
  95.         {
  96.                 mTrans = transform;
  97.  
  98.                 if (checkSprite != null) checkSprite.alpha = startsChecked ? 1f : 0f;
  99.  
  100.                 if (option)
  101.                 {
  102.                         option = false;
  103.                         if (radioButtonRoot == null) radioButtonRoot = mTrans.parent;
  104.                 }
  105.         }
  106.  
  107.         /// <summary>
  108.         /// Activate the initial state.
  109.         /// </summary>
  110.  
  111.         void Start ()
  112.         {
  113.                 if (eventReceiver == null) eventReceiver = gameObject;
  114.                 mChecked = !startsChecked;
  115.                 mStarted = true;
  116.                 Set(startsChecked);
  117.         }
  118.  
  119.         /// <summary>
  120.         /// Check or uncheck on click.
  121.         /// </summary>
  122.  
  123.         void OnClick () { if (enabled) isChecked = !isChecked; }
  124.  
  125.         /// <summary>
  126.         /// Fade out or fade in the checkmark and notify the target of OnChecked event.
  127.         /// </summary>
  128.  
  129.         void Set (bool state)
  130.         {
  131.                 if (!mStarted)
  132.                 {
  133.                         mChecked = state;
  134.                         startsChecked = state;
  135.                         if (checkSprite != null) checkSprite.alpha = state ? 1f : 0f;
  136.                 }
  137.                 else if (mChecked != state)
  138.                 {
  139.                         // Uncheck all other checkboxes
  140.                         if (radioButtonRoot != null && state)
  141.                         {
  142.                                 UICheckboxPlus[] cbs = radioButtonRoot.GetComponentsInChildren<UICheckboxPlus>(true);
  143.  
  144.                                 for (int i = 0, imax = cbs.Length; i < imax; ++i)
  145.                                 {
  146.                                         UICheckboxPlus cb = cbs[i];
  147.                                         if (cb != this && cb.radioButtonRoot == radioButtonRoot) cb.Set(false);
  148.                                 }
  149.                         }
  150.  
  151.                         // Remember the state
  152.                         mChecked = state;
  153.  
  154.                         // Tween the color of the checkmark
  155.                         if (checkSprite != null)
  156.                         {
  157.                                 if (instantTween)
  158.                                 {
  159.                                         checkSprite.alpha = mChecked ? 1f : 0f;
  160.                                 }
  161.                                 else
  162.                                 {
  163.                                         TweenAlpha.Begin(checkSprite.gameObject, 0.15f, mChecked ? 1f : 0f);
  164.                                 }
  165.                         }
  166.  
  167.                         current = this;
  168.  
  169.                         // Notify the delegate
  170.                         if (onStateChange != null) onStateChange(mChecked);
  171.  
  172.                         // Send out the event notification
  173.                         if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
  174.                         {
  175.                                 eventReceiver.SendMessage(functionName, mChecked, SendMessageOptions.DontRequireReceiver);
  176.                         }
  177.                         current = null;
  178.  
  179.                         // Play the checkmark animation
  180.                         if (checkAnimation != null)
  181.                         {
  182.                                 ActiveAnimation.Play(checkAnimation, state ? Direction.Forward : Direction.Reverse);
  183.                         }
  184.                 }
  185.         }
  186. }
  187.  

11
NGUI 3 Support / UICheckbox CheckSprite
« on: September 05, 2013, 12:02:02 PM »
I would like to use a GameObject with a UITexture as the Check Sprite. Right now I'm limited to using a UISprite. Any thoughts on how I can make that happen?

Thanks!

12
NGUI 3 Support / Orphaned GUI Elements solution?
« on: August 29, 2013, 01:55:42 PM »
I brought this up last week and nothing was resolved. It was thought that NGUI was updated improperly but after confirming it was indeed updated correctly, the issue still stood.

I'm coming back now with some findings:

It seems that if UI elements are deeply nested, there is something about it that breaks and causes them to become orphaned and require either restarting Unity or Force Deleting the objects. The bug only begins after entering Play mode, you'll see the UI elements 'stuck' and don't go away even after disabling them, and even after exiting Play mode.

Our only solution now is to just not nest UI elements so deeply.

13
NGUI 3 Support / NGUI stray UI elements
« on: August 23, 2013, 09:39:06 AM »
My team is having this strange issue where a panel is displayed, but when it is turned off, some of the UI elements that don't actually exist in the hierarchy stay in the scene. We found that they could be Force Deleted from the Game Object menu, but that doesn't help during runtime.

I've attached an image of the issue.

Any ideas on how to prevent this from happening?

Thanks,

-Jacob S.


14
Other Packages / StarLink GameWebRequest
« on: August 22, 2013, 11:00:07 AM »
Could someone give me a good example of how to use the GameWebRequest script. I've tried quite a few different ways to get it working.

I'm trying to use it to download a .png and assign it to a Texture2D variable.

Thanks

-Jacob S

15
NGUI 3 Support / Variable Names
« on: August 21, 2013, 10:06:05 AM »
I'm just wondering why variable names are named as such:
I see this a lot in NGUI source, the variable starts with 'm'.

  1. static string mName;
  2. static int mFull = -1;
  3. static int mHints = -1;
  4. static int mWifi = -1;
  5. static int mExp = -1;
  6. static int mPowerSaving = -1;

Pages: [1] 2