• 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 /
avatar image
Question by TBOPFalcon · Aug 15, 2015 at 02:04 PM · il2cpp64-bit64bit64

Some scripts not running on device with IL2CPP

Some scripts not running on device with IL2CPP

I have been working on my project with Mono2X, testing in Unity simulator and on device with no issues. After realising I need to start supporting ARM64 architecture, I switched to IL2CPP and crossed my fingers. For some reason, two of my scripts just plain aren't running. A print line in the 'Awake' function (that prints fine in simulator) isn't hit on device, and a print for the object.Getcomponent(scriptname) = blank. Not null, but blank - like it doesn't exist.

Both scripts have been downloaded as part of a Unity Asset store feature which is suspect, but both are js scripts much like my others and I can't find a reason why they would act differently.

Any ideas? Again, the scripts run beautifully on device in Mono2x. Any help would be greatly appreciated as I'm ready to submit once this is resolved :p

Here is one of the scripts for reference

 ///////////////////////////////////////////////
 ////       ImageDisplayXYHorizontal.js      ////
 ////  copyright (c) 2011 by Markus Hofer   ////
 ////          for GameAssets.net           ////
 ///////////////////////////////////////////////
 
 var swipeCtrl : SwipeControlXY;
 
 //IMAGES
 var img = new Texture2D[13]; //Array of Images, all images need to have the same dimensions!
 var imgRect : Rect; //Leave empty to use img-dimensions and place in the center of the matrix - this can be used to offset the image from the center of the matrix!
 
 //MATRIX
 var centerMatrixOnScreen : boolean = true; //Check this to move the matrix to the center of the screen (any value in MatrixPosition will be added to this = offset from center)
 var matrixPosition : Vector3 = Vector3.zero; //This is the center of the matrix, use this to position the control - everything will rotate around this point!
 private var prevMatrixPosition : Vector3;
 var matrixAngle : float = 0.0; //Use this to rotate the GUI //formerly known as globalAngle
 private var previousAngle : float; //used to check if the Angle changed, so the Quaternion doens't have to be calculated every frame
 private var quat : Quaternion = Quaternion.identity;
 private var matrix : Matrix4x4;
 var expandInputAreaToFullWidth : boolean = false; //Use the full width (left and right of the image) for swiping?
 
 //OPTIONS
 var displayAll : boolean = false; //Display all images, don't fade out the unselected ones...
 
 //DOTS
 var dot = new Texture2D[2]; //Dots - First is inactive, second is active. Set Array-length to 0 to hide the dots entirely
 var dotRelativeCenterPos : Vector2; //Position of the dots, relative to the center of imgRect
 
 //DEBUG OPTIONS
 var debug : boolean = false; //Show Debug Stuff
 var debugBoxStyle : GUIStyle;
 
 var native_width : float = 1136;
 var native_height : float = 640;
 
 function Awake () {
 
     print("Image Display XY Horizontal Awake");
 
     if(!swipeCtrl) swipeCtrl = gameObject.GetComponent("SwipeControlXY"); //Find SwipeControl on same GameObject if none given
 
     if(!dot[0] || !dot[1]) Debug.LogWarning("If you want to hide the dots, set the dot array length to 0 and don't just leave the slots empty!");
 
     if(imgRect == new Rect(0,0,0,0)) { //If no rect given, create default rect
         imgRect = new Rect(-img[0].width * 0.5, -img[0].height * 0.5, img[0].width, img[0].height);
     }
     
     //Set up SwipeControl
     swipeCtrl.pxDistBetweenValues.x = img[0].width;
     swipeCtrl.maxValue.x = img.Length - 1;
     if(expandInputAreaToFullWidth) {
         swipeCtrl.SetActiveArea(new Rect(-Screen.width * 0.5, imgRect.y, Screen.width, imgRect.height)); // Use image-height for the input-Rect, but full screen-width
     } else {
          swipeCtrl.SetActiveArea(imgRect); //Use the same Rect as the images for input
     }
     swipeCtrl.CalculateEdgeRectsFromActiveArea(imgRect);
     swipeCtrl.Setup();
     
     //Determine center position of the Dots
     if(dotRelativeCenterPos == Vector2.zero) dotRelativeCenterPos.y = imgRect.height * 0.5 + 14;
     dotRelativeCenterPos = new Vector2((imgRect.x + imgRect.width * 0.5) + dotRelativeCenterPos.x, (imgRect.y + imgRect.height * 0.5) + dotRelativeCenterPos.y);
 
     if(centerMatrixOnScreen) { 
         matrixPosition.x += Mathf.Round(Screen.width * 0.5);
         matrixPosition.y += Mathf.Round(Screen.height * 0.7);
         
         
     }
     
 }
 
 
 function OnGUI () {
 
         print("Image Display XY Horizontal GUI");
 
     var rx : float = Screen.width / native_width;
     var ry : float = Screen.height / native_height;
     GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (rx, ry, 1)); 
     // GUI MATRIX
     if(matrixAngle != previousAngle || matrixPosition != prevMatrixPosition) { //only calculate new Quaternion if angle changed
         quat.eulerAngles = Vector3(0.0, 0.0, matrixAngle);
         previousAngle = matrixAngle;
         matrix = Matrix4x4.TRS(matrixPosition, quat, Vector3.one);    //If you're no longer tweaking
         prevMatrixPosition = matrixPosition;
         swipeCtrl.matrix = matrix; // Tell SwipeControl to use the same Matrix we use here
     }
     GUI.matrix = matrix;        
 
 
     // IMAGES
     if(displayAll) { //display all images
             
         for(var j : int = 0; j < img.Length; j++) {
             print("img[j] = " + img[j]);
             GUI.DrawTexture(new Rect(imgRect.x + imgRect.width * j - swipeCtrl.smoothValue.x * imgRect.width, imgRect.y, imgRect.width, imgRect.height), img[j]);
         }
                                 
     } else { //only display the selected one and fade the previous and next image in and out
         
         var offset : float = swipeCtrl.smoothValue.x - Mathf.Round(swipeCtrl.smoothValue.x);
         var mainPos : float = imgRect.x - (offset * imgRect.width);
         
         if(Mathf.Round(swipeCtrl.smoothValue.x) >= 0 && Mathf.Round(swipeCtrl.smoothValue.x) < img.length) {
             GUI.color.a = 1 - Mathf.Abs(offset);
             GUI.DrawTexture(new Rect(mainPos, imgRect.y, imgRect.width, imgRect.height), img[Mathf.Round(swipeCtrl.smoothValue.x)]);
         }
         GUI.color.a = -offset;
         if(GUI.color.a > 0.0 && Mathf.Round(swipeCtrl.smoothValue.x) - 1 >= 0 && Mathf.Round(swipeCtrl.smoothValue.x) - 1 < img.length) {
             GUI.DrawTexture(new Rect(mainPos - imgRect.width, imgRect.y, imgRect.width, imgRect.height), img[Mathf.Round(swipeCtrl.smoothValue.x) - 1]);
         }
         GUI.color.a = offset;
         if(GUI.color.a > 0.0 && Mathf.Round(swipeCtrl.smoothValue.x) + 1 < img.length && Mathf.Round(swipeCtrl.smoothValue.x) + 1 >= 0) {
             GUI.DrawTexture(new Rect(mainPos + imgRect.width, imgRect.y, imgRect.width, imgRect.height), img[Mathf.Round(swipeCtrl.smoothValue.x) + 1]);
         }
         GUI.color.a = 1.0;
     
     }
 
     // DOTS
     if(dot.Length > 0) {
         for(var i = 0; i < img.Length; i++) {
             var activeOrNot : boolean = false;
             if(i == Mathf.Round(swipeCtrl.smoothValue.x)) activeOrNot = true; 
             if(!activeOrNot) GUI.DrawTexture(new Rect(dotRelativeCenterPos.x - (img.Length * dot[0].width * 0.5) + (i * dot[0].width), Mathf.Round(dotRelativeCenterPos.y - (dot[0].height * 0.5)), dot[0].width, dot[0].height), dot[0]);
             else GUI.DrawTexture(new Rect(Mathf.Round(dotRelativeCenterPos.x - (img.Length * dot[0].width * 0.5) + (i * dot[0].width)), Mathf.Round(dotRelativeCenterPos.y - (dot[0].height * 0.5)), dot[0].width, dot[0].height), dot[1]);
             //GUI.Toggle(new Rect((centerPos.x - (dotStatusArray.Length * 13 * factor * 0.5) + (i * 13 * factor)), (centerPos.y - (13 * factor * 0.5)), 13 * factor, 13 * factor), activeOrNot, GUIContent.none, guiStyle);    
         }    
     }
 
     
     //If you have the BlackishGUI-script you can simply call the following function instead of the above code
     //BlackishGUI.Dots(dotRelativeCenterPos, img.Length, Mathf.Round(swipeCtrl.smoothValue.x));
     
 
     //DEBUG info
     if(debug) {
         GUI.Box(new Rect(-2,-2,4,4), GUIContent.none, debugBoxStyle);
         GUI.Box(imgRect, "imgRect with matrix", debugBoxStyle);    
         GUI.Box(swipeCtrl.leftEdgeRectForClickSwitch, "<<", debugBoxStyle);
         GUI.Box(swipeCtrl.rightEdgeRectForClickSwitch, ">>", debugBoxStyle);
         GUI.Box(swipeCtrl.activeArea, "activeArea", debugBoxStyle);
 
         GUI.matrix = Matrix4x4.identity;
         GUI.Label(new Rect(Input.mousePosition.x + 15, Screen.height - Input.mousePosition.y - 15, 200, 100), "screen-mouse: " + Input.mousePosition.x + ", " + Input.mousePosition.y + "\nscreen-touch + gui: " + Input.mousePosition.x + ", " + (Screen.height - Input.mousePosition.y));
 
         var mPos : Vector3 = Vector3(Input.mousePosition.x - (Screen.width * 0.5), Input.mousePosition.y - (Screen.height * 0.5), 0.0);
         var tmPos : Vector3 = swipeCtrl.matrix.MultiplyPoint3x4(mPos);
         var tmPosC : Vector2 = Vector2(tmPos.x - (Screen.width * 0.5), tmPos.y - (Screen.height * 0.5));
         var ttPosC : Vector2 = Vector2(tmPos.x - (Screen.width * 0.5), (Screen.height - tmPos.y) - (Screen.height * 0.5));
         GUI.Label(new Rect(Input.mousePosition.x + 15, Screen.height - Input.mousePosition.y + 15, 200, 100), "matrix-mouse: " + Mathf.Round(tmPosC.x) + ", " + Mathf.Round(tmPosC.y) + "\nmatrix-touch + gui: " + Mathf.Round(ttPosC.x) + ", " + (Mathf.Round(ttPosC.y)));
     }
 
 
     
 }
Comment

People who like this

0 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 · Aug 24, 2015 at 05:46 PM 0
Share

Nothing here jumps out at me as being a specific problem with IL2CPP. This should work correctly. You may want to try debugging the generated C++ cope in Xcode. This blog post has some general information about debugging IL2CPP generated code: http://blogs.unity3d.com/2015/05/20/il2cpp-internals-debugging-tips-for-generated-code/

avatar image alexisod · Sep 10, 2015 at 06:29 PM 0
Share

@TBOPFalcon I've got the same issues with the same SwipeControlXY scripts. Have you found a solution to this since your post?

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by TBOPFalcon · Sep 11, 2015 at 03:45 AM

YES @alexisod ! I managed to fix this with the most ridiculous fix. I copied the script into a new script and re-hooked up all the variables and it worked fine. It seems perhaps IL2CPP takes issue with imported scripts? Either way I hope this works for you bud. I bugged it with Unity and they have reproduced it using my project / are looking into it.

Comment

People who like this

0 Show 2 · Share
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 alexisod · Sep 11, 2015 at 08:44 PM 0
Share

Wow @TBOPFalcon ok! Just clarifying: did you copy the ImageDisplayXYHorizontal.js and SwipeControlXY.js scripts or your customer scripts from which you referenced these?

avatar image TBOPFalcon · Sep 12, 2015 at 05:52 PM 0
Share

That's right! I just copied the body into a new js file and hooked it up / removed the originals. Weird but it did the job! Let me know if it does for you.

avatar image

Answer by alexisod · Sep 12, 2015 at 02:06 AM

@TBOPFalcon I think I nailed it!

These particular scripts come in 2 versions: C# and JS. The problem seems to occur when you use the JS version - GetComponent() seems to get confused.

I deleted the .cs files (actually moved them out of /Assets) and we are back in business!

Comment

People who like this

0 Show 0 · Share
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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

No Android APK is made when building 64-bit - IL2CPP error 2 Answers

Unity www class crashes on iOS 64 bit 2 Answers

IL2CPP - RPC doesn't work 1 Answer

64-Bit Error in iOs Unity App 0 Answers

Out of memory errors on iOS with 64-bit build 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