Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by TabTaleTravis · Jan 05, 2016 at 07:30 PM · unity 5iosbuild settingsil2cpp

How Do I Ensure that --enable-unity-event-support is Set for iOS Builds?

Hey all, I've been getting NullReferenceExceptions for my IL2CPP builds whenever I call AddListener() on my derived UnityEvent. Here is my UnityEvent derivative:

 [Serializable]
 public class TweenEvent : UnityEvent<Tween> { }

Here is the code that's getting called:

 // setup the in-Tween
 _inTween = gameObject.AddComponent<PositionTween>();
 _inTween.TweenFinished.AddListener(HandleTransitionInTweenFinished); // exception occurs
 _inTween.Curve = new AnimationCurve(EaseInKeyframes);
 _inTween.Begin = new Vector3(TransitionDistance, 0.0f, 0.0f);
 _inTween.End = Vector3.zero;
 _inTween.Duration = TransitionDuration;


The NullReferenceException happens with AddListener(), but that's all the information I get. I've verified that _inTween and _inTween's TweenFinished property (TweenEvent) are not null using debug logs. I get no runtime exceptions or have any issues with my code in the editor or with builds on Android devices. Everything runs fine on iOS when I use Mono2x instead of IL2CPP. I need to use IL2CPP though.

I'm also using Unity 5.1.2f on OS X El Capitan. I'm not able to upgrade my version of Unity due to our internal framework's compatibility managed by another team.

Also, is there a way that I can verify that --enable-unity-event-support is being passed to il2cpp when making iOS builds from OS X?

UPDATE: I did a test with C# delegates instead of UnityEvents, and I got the same error. Here's the error I get in Xcode:

 NullReferenceException: A null value was found where an object instance was required.
   at Step.Setup (Controller controller, UnityEngine.RectTransform spawnTransform) [0x00000] in <filename unknown>:0 
   at Controller+<ProcessLoadStep>c__Iterator9.MoveNext () [0x00000] in <filename unknown>:0 

It still happens at the AddListener() line. Here's the complete Setup() method that I'm having trouble with:

 public void Setup(Controller controller, RectTransform spawnTransform)
     {
         // get the RectTransform, and assign the Parent controller
         RectTransform rectTransform = (RectTransform)transform;
         Parent = controller;
         if(Parent != null)
         {
             // setup the RectTransform
             rectTransform.SetParent(spawnTransform);
             rectTransform.offsetMin = Vector2.zero;
             rectTransform.offsetMax = Vector2.one;
             rectTransform.localScale = Vector3.one;
                 
             // setup the in-Tween
             _inTween = gameObject.AddComponent<PositionTween>();
             _inTween.TweenFinished.AddListener(HandleTransitionInTweenFinished); // EXCEPTION
             _inTween.Curve = new AnimationCurve(EaseInKeyframes);
             _inTween.Begin = new Vector3(TransitionDistance, 0.0f, 0.0f);
             _inTween.End = Vector3.zero;
             _inTween.Duration = TransitionDuration;
                 
             // setup the out-Tween
             _outTween = gameObject.AddComponent<PositionTween>();
             _outTween.TweenFinished.AddListener(HandleTransitionOutTweenFinished); // EXCEPTION
             _outTween.Curve = new AnimationCurve(EaseInKeyframes);
             _outTween.Begin = Vector3.zero;
             _outTween.End = new Vector3(-TransitionDistance, 0.0f, 0.0f);
             _outTween.Duration = TransitionDuration;
         }
     }

This suggests that my private HandleTransitionIn(Out)TweenFinished() methods are null, but how can that be? The GameObject and component instance are both created. I also get more NullReferenceExceptions through the runtime of my game on iOS/IL2CPP that never occurs on iOS/Mono or Android builds.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JoshPeterson · Jan 06, 2016 at 12:52 PM 0
Share

You may want to try to debug the generated C++ code in Xcode in this case. That might lend some insight about what is causing the exception. You can find some details about how to do this on the blog post here:

http://blogs.unity3d.com/2015/05/20/il2cpp-internals-debugging-tips-for-generated-code/

We also have a demo about debugging generated code from Unite 2015 here:

https://youtu.be/s7Ple1G83jc

One other note: you can see the command line that il2cpp.exe is called with in the Editor log file. Search it for "il2cpp".

avatar image TabTaleTravis · Jan 08, 2016 at 12:53 AM 0
Share

I couldn't find anything in Editor.log regarding il2cpp. I was looking under ~/Library/Logs/Unity/Editor.log on OS X. I also looked through the other log files in that directory, but found nothing.

As far as debugging the internals, I wouldn't be able to submit the Xcode project. Our projects get built through Jenkins, which is all remotely handled by our HQ. I have limited control over tweaking the build process.

Although I get quite a few exceptions throughout my game at runtime, this is the only instance that appears to break something so far. It sounds like Unity's gone through quite a bit of IL2CPP maturity since 5.1.2, but I'm obligated to get this to work with 5.1.2. Are there any workarounds that I can do in C#? I've tried converting that UnityEvent into a C# delegate, but I get the same exception. To me, this suggests that this isn't a UnityEvent, but an event handler issue.

Could it be possible that "HandleTransitionInTweenFinished()" is somehow generating the NullReferenceException? I've verified that the GameObject and component of my handler method are both instantiated and attached about 500ms + 3 frames ahead of time lol.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

49 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 5.2 ios IL2CPP build gives null reference exception 0 Answers

IL2CPP Build error Unity 5.3.1p4 0 Answers

[Not Answered] Fog not working iOS Build 2 Answers

ios build times slow for now reason 0 Answers

[SOLVED] In game narration system 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges