Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by mihir solanki · Jun 26, 2015 at 11:34 PM · androidcamerainstantiateunity5main camera

main camera destroying in editor but not in android

i am trying to spawn a player with a first person controller when the user presses any one of the two gui buttons on my amin camera.this works fine in the editor and the camera gets destroyed but in android it still shows the main camera view without switching to the players camera.the gui buttons also get activated and the debug.log gets executed,but the camera just does nt switch or destroy.please help! my code:

 //gui logic
 var originalWidth = 640.0;
 var originalHeight = 400.0;
 private var scale: Vector3;
 var my:GUISkin;
 //player 
 var player:GameObject;
 //positions
 var pos1:GameObject;
 var pos2:GameObject;
 
 
 function OnGUI()
     {
     GUI.skin=my;
     scale.x = Screen.width/originalWidth;
     scale.y = Screen.height/originalHeight;
     scale.z = 1;
     var svMat = GUI.matrix;
     GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
     if(GUI.Button (Rect (originalWidth - 430,originalHeight - 350,50,50), "ROOF:1"))
     {
     
       player.transform.position=pos1.transform.position;
       player.transform.rotation=pos1.transform.rotation;
       player.SetActive(true);
       transform.GetComponent(Camera).enabled=false;
        GameObject.Destroy(gameObject);
      Debug.Log("Spawning");
        }
     if(GUI.Button (Rect (originalWidth - 200,originalHeight - 350,50,50), "ROOF:2"))
     {
    
       player.transform.position=pos2.transform.position;
       player.transform.rotation=pos2.transform.rotation;
       player.SetActive(true);
           transform.GetComponent(Camera).enabled=false;
         GameObject.Destroy(gameObject);
         Debug.Log("Spawning");
      
       }
     if(GUI.Button (Rect (originalWidth - 640,originalHeight - 400,50,50), "Back"))
     {
      Application.LoadLevel(0);
      }
       GUI.matrix = svMat;
      }
      
     
     
     
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 Mastasytha · Jun 27, 2015 at 02:03 PM 0
Share

What game object is connected to the script

avatar image mihir solanki · Jun 28, 2015 at 05:31 AM 0
Share

an untagged camera named as $$anonymous$$ain Camera under a gameobject called map

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by DiegoSLTS · Jun 27, 2015 at 12:57 AM

Change the tag of the new camera to MainCamera after destroying the main camera.

When you remove the MainCamera in the editor, the image drawn by that camera gets cleared, but on builds it doesn't work the same way and you start getting this weird behaviours.

Comment
Add comment · 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 mihir solanki · Jun 27, 2015 at 05:20 AM 0
Share

ok will try

avatar image mihir solanki · Jun 27, 2015 at 01:40 PM 0
Share

i did that but it still shows the previous camera view

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Reading XML Data for andriod 1 Answer

Joystick isn't recognize by Unity when i activate CardBoard option 0 Answers

Make camera follow an instantiated object 1 Answer

Why do get lag when rotating a camera on android ? 0 Answers

Screenshot function not working properly ,it records button on UI ? 0 Answers


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