• 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 atique6 · Mar 08, 2014 at 08:53 PM · androidapk

Speedometer not working on phone

Speedometer just working fine on editor, but it's not working on phone after building .apk. Can anyone please help? Thanks in advance.

Comment
Add comment · Show 4
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 Gruffy · Mar 08, 2014 at 09:26 PM 0
Share

$$anonymous$$aybe your phone model does not have one!? Silly really I know, but quite possible. Especially as I wouldnt have any idea what phone you are testing on/ deploying to etc. Take care Gruffy

avatar image atique6 · Mar 08, 2014 at 09:38 PM 0
Share

Samsung Galaxy Trend 7293, but it involves just using two textures and a script, the speedometer using just digits works fine @Gruffy

avatar image Gruffy · Mar 09, 2014 at 12:15 AM 0
Share

so you are getting value changes in a gui label, box, or something similar on screen your when you test on the phone, but when you replace the gui values with a texture to represent them , you get nothing appearing?.

How have you implemented the value change invoking the texture to change (either positionally or through texture swaps based on speedometer value). I guess,I`m saying... Please post your script, and I/we can see your problem in the code. By showing us your code, we might be able to see the fault glaring away at us.

This is "Unity Answers" after all my dear man, not "Unity Guessers" No offense intended, just over emphasizing my ambition to reach clairvoyance has, as yet, not been granted. take care bud and thanks for reading this latest installment. Gruffy

avatar image atique6 · Mar 09, 2014 at 09:17 PM 0
Share

Thanks for ur kind reply and sorry for my late response. the code is as follows:

using UnityEngine; using System.Collections;

public class Speedo : $$anonymous$$onoBehaviour { public Texture2D dialTex; public Texture2D needleTex; public Vector2 dialPos; public float topSpeed; public float stopAngle; public float topSpeedAngle; public float speed = 20; public float needleAngle;

 public GameObject car1;
 public GameObject car2;
 public GameObject car3;
  
 

  

 void  OnGUI (){
     GUI.DrawTexture( new Rect(dialPos.x, dialPos.y, dialTex.width, dialTex.height), dialTex);
        Vector2 centre= new Vector2(dialPos.x + dialTex.width / 2, dialPos.y + dialTex.height / 2);
     $$anonymous$$atrix4x4 saved$$anonymous$$atrix= GUI.matrix;
      float   speedFraction = speed / topSpeed;
     needleAngle= $$anonymous$$athf.Lerp(stopAngle, topSpeedAngle, speedFraction);
     GUIUtility.RotateAroundPivot(needleAngle, centre);
     GUI.DrawTexture( new Rect(centre.x, centre.y - needleTex.height / 2, needleTex.width, needleTex.height), needleTex);
     GUI.matrix = saved$$anonymous$$atrix;
 


     float kph1= car1.rigidbody.velocity.magnitude * 3.6f;
     float kph2= car2.rigidbody.velocity.magnitude * 3.6f;
     float kph3= car3.rigidbody.velocity.magnitude * 3.6f;

     speed = kph2;

 }

} In the unity editor the code works fine as i said before. Interesting matter is that if i use: speed += any digit(for example speed +=10), only then the needle in the speedometer rotates.

2 Replies

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

Answer by atique6 · Mar 10, 2014 at 01:32 PM

The problem is solved. I converted the javascript to c# and it didn't work. Don't know where's the wrong. May be for inaccurate conversion, though it didn't matter while playing in the editor. Now using the javascript version of the code works both for unity editor and my android phone.

Comment
Add comment · Show 3 · 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 Gruffy · Mar 10, 2014 at 04:44 PM 0
Share

Well done bud, you sorted it out on your own, that`s what this is equally about i`d say. helping yourself here seems to ultimately help others too. Nicely solved $$anonymous$$y apologies too, as I struggled to make it back to a here in time to help you out until now. Absolutely well done though, I bet it felt good when it finally worked eh.

Take care Gruffy

avatar image atique6 · Mar 13, 2014 at 02:43 PM 0
Share

The problem was that in the speedometer script, i needed to access some variables used in a car controller script that was a javascript, therefore, the c# version of the Speedometer failed to access those variables and did not work, and finally it wroked using the javascript version of Speedometer as it successfully accessed the variables used in another javascript. Anyways, thanks a lot for ur effort to help :) Guys like u r surely helping hands to unity newbies @Gruffy .

avatar image Gruffy · Mar 13, 2014 at 04:25 PM 0
Share

Thanks mate @atique6, for both your kind words and appreciation of Unity Answers .. So in conclusion, your actual problem was accessing a script outside of the common language your are using, in this case C#. I have an idea that you may be able to refactor again or even revert to your original solution, but working with Unity`s script compilation order to ensure your UnityScript variables found in your car controller script can be accessed through a C# script.

I have linked you to the Unity docs below to a page you may find useful to your original problem bud. Unity 3D Special Folders and Script Compilation Order Also, UnityGems has some really inisghtful reading regarding common Unity "Gotchas". here is link to that too, in case you have yet to discover it... Unity Gems - Common Gotchas Page Go to 3rd up from bottom tab and click that on website Take care Bud. Gruffy

avatar image
0

Answer by atique6 · Mar 10, 2014 at 01:32 PM

the problem is solved.

Comment
Add comment · Show 5 · 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 haim96 · Mar 10, 2014 at 01:34 PM 0
Share

does any one helped you? i will convert his comment to answer and you will select it as the answer.

avatar image atique6 · Mar 10, 2014 at 01:54 PM 0
Share

No. I helped myself @haim96.

avatar image haim96 · Mar 10, 2014 at 01:56 PM 0
Share

then select your own answer and close this thread. thank you!

avatar image atique6 · Mar 10, 2014 at 01:59 PM 0
Share

i have accepted my answer, but how to close the thread, i have no idea. @haim96 ?

avatar image haim96 · Mar 10, 2014 at 02:58 PM 0
Share

Thats it. Your done.

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

22 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

Related Questions

APK size 70 mb more then editor log 0 Answers

Android / Split apk / obb can't load a scene 1 Answer

After installing the .APK I see the app icon twice 1 Answer

Why APK freezes at start of game level? 0 Answers

Issue installing apk using old Cert 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