• 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
0
Question by Itinerant · Oct 31, 2013 at 11:13 PM · androidenabledrenderer.enabled

renderer.enabled working on PC but not android?

This is confusing me, I'm not quite sure what's going on. I'm trying to enable/disable the renderers of a set of child gameObjects. Testing it in the editor, it works perfectly. When I build it out and try it on my tablet, it doesn't work at all.

All of my test variables behave as expected, except one: whichObject.transform.GetChild(0).renderer.enabled returns 'false' every time on android, regardless of the state of the game object. Anyone know why?

         if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){

                 Ray ray = guiCamera.ScreenPointToRay(Input.GetTouch (0).position);
                 RaycastHit hit;
             
                 if(Physics.Raycast (ray, out hit, guiLayerMask)){
                     testButton = "Hit Button: "+hit.collider.transform.parent.name;
                     WhichButtonPressed(hit.collider.transform.parent.name);
                 }
         }

Skipping down to the relevant bit:

     case "removeExtWalls" : 
                 testButton = "removeExtWalls"; //To make sure I'm actually presssing the building
                 whichObject = GameObject.FindWithTag("extWalls");
                 turnOn = !whichObject.transform.GetChild(0).renderer.enabled;
                 testObject = whichObject.name;
                 testButtonStatus = whichObject.transform.GetChild(0).renderer.enabled.ToString(); //Always returns 'true' on android, changes as expected in editor
                 foreach(Transform subObject in whichObject.transform){
                     subObject.renderer.enabled = false;
                 }
                 break;
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 Itinerant · Oct 31, 2013 at 11:26 PM 0
Share

Ok....so it turns out that the code on the top registers two hits each time I touch it, even though the phase is set to began...anyone know why?

avatar image Itinerant · Oct 31, 2013 at 11:32 PM 0
Share

This looks like my problem, but I have this function in Update(), not FixedUpdate()

http://answers.unity3d.com/questions/220776/ios-touchphasebegan-detected-multiple-times.html

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Itinerant · Oct 31, 2013 at 11:50 PM

Alright, solved my own problem. The issue was that my input detection script was part of a function, and that function was in Update(). When I put the touch detection portion of the script directly into the Update() function, it worked fine.

Comment
Add comment · 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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 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

Related Questions

Canvas no longer appearing in Android build 1 Answer

.enabled with Android 1 Answer

Launching My Unity App from a Notification 2 Answers

Aiming (Rotation) an object to User Touch Input 0 Answers

android audio delayed 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges