Problem: We lose the GUI elements of a scene when ByteCode stripping is enabled. Works fine in the IDE. Works fine on the iPhone when Stripping Level is Disabled.
Background: I know this has been posted before, and I have read all the threads I can find, but did not see it solved definitively. The threads either say “it will be fixed in the next version” or recommend the workaround:
private var tmp:TextEditor = new TextEditor();
(Where in the script does that go, exactly??)
The workaround does not work. Specifically, are using iPhone Advanced, and with ByteCode Stripping enabled, scenes with GUI textures, GUI text and other OnGUI() elements do not show up on the iPhone.
I have submitted our project to Unity Support, but we can’t just wait until whenever the next version ships. Anyone have suggestions for other things I can try?
Thanks all!
P.S. Props to Gravek for 10 Balls 7 Cups. Respect.
Have you placed this in the script that holds your OnGui code?
I did: no dice.
Actually, I put it up at the top with the global vars – do I need to put it in the OnGUI() function?
if the workaround does not fix it your only options are:
- go to a less agressive stripping for the moment
- wait for Unity iPhone 1.1
Sure – but none of the stripping schemes work. They all cause the scroll windows to disappear. iPhone crash log for OnGUI() calls:
Sat Mar 14 09:49:24 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: UnityEngine.GUILayout.BeginScrollView (Vector2 scrollPosition, UnityEngine.GUILayoutOption[] options) [0x00000]
Sat Mar 14 09:49:24 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: credits.OnGUI ()
Sat Mar 14 09:49:24 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>:
Sat Mar 14 09:49:24 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: (Filename: Line: -1)
Sat Mar 14 09:49:24 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: ArgumentException: Getting control 1's position in a group with only 1 controls when doing Repaint
Sat Mar 14 09:49:24 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: Aborting
Sat Mar 14 09:49:24 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: MissingMethodException: Method not found: 'Default constructor not found...ctor() of UnityEngine.GUIScrollGroup'.
Sat Mar 14 09:49:25 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: MissingMethodException: Method not found: 'Default constructor not found...ctor() of UnityEngine.GUIScrollGroup'.
Sat Mar 14 09:49:25 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: UnityEngine.GUILayout.BeginScrollView (Vector2 scrollPosition, UnityEngine.GUILayoutOption[] options) [0x00000]
Sat Mar 14 09:49:25 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: credits.OnGUI ()
Sat Mar 14 09:49:25 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>:
Sat Mar 14 09:49:25 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: (Filename: Line: -1)
Sat Mar 14 09:49:25 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: ArgumentException: Getting control 1's position in a group with only 1 controls when doing Repaint
Sat Mar 14 09:49:25 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: Aborting
Sat Mar 14 09:49:25 unknown configd[21] <Notice>: WiFi: Display off. Adjusting scan intervals for dim screen.
Sat Mar 14 09:49:25 unknown configd[21] <Notice>:
Sat Mar 14 09:49:25 unknown configd[21] <Notice>: WiFi: Disassociation timer disabled because we are connected to a power source
Sat Mar 14 09:49:26 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: MissingMethodException: Method not found: 'Default constructor not found...ctor() of UnityEngine.GUIScrollGroup'.
Sat Mar 14 09:49:26 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: UnityEngine.GUILayout.BeginScrollView (Vector2 scrollPosition, UnityEngine.GUILayoutOption[] options) [0x00000]
Sat Mar 14 09:49:26 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: credits.OnGUI ()
Sat Mar 14 09:49:26 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>:
Sat Mar 14 09:49:26 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: (Filename: Line: -1)
Sat Mar 14 09:49:26 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: ArgumentException: Getting control 1's position in a group with only 1 controls when doing Repaint
Sat Mar 14 09:49:26 unknown UIKitApplication:com.atomicpistol.StarJumper_[0xd3ba][3072] <Notice>: Aborting
Which kind of obviates the advantages of iPhone Advanced, IMO.
No response from Unity Support yet… Oh well.
Hello wrathpanda,
PM me your bug number. In general I would recommend to avoid GUI sliders and scroll views until Unity iPhone 1.1 is released, just try to redesign your gui in another way for the moment.
Hello,
your help is much appreciated.
Regards,
I had a GUI.TextField, a GUI.Box, and a GUI.Label that disappeared when stripping was enabled.
I added the suggested TextEditor line (it’s C# equivalent) to the class itself, not the OnGUI method.
So after my class declaration:
public class MyClassForGUI : MonoBehaviour
{
but before any methods, I placed the following line of code:
private TextEditor _te = new TextEditor();
By doing this, my GUI reappeared in the stripped version, and I can now run my app with another 6MB shaved off.
For UnityScript, try using the single line of code workaround in the original post, but place it OUTSIDE of (before) any methods in the script.
Caveat: I haven’t yet tried scroll bars.