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 fuka10 · May 09, 2014 at 05:04 PM · inspectorvariables

inspector isnt showing scripts

i have little problem with unity

Iam new to unity so it could be obvious. As you can see in the picture i cant see or change the variables in the script even though they are public. Please Help.

Thank you in advance

alt text

unity error.png (62.5 kB)
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 Jasper-Flick · May 09, 2014 at 06:45 PM 0
Share

Without your script code we can't deter$$anonymous$$e what's wrong.

avatar image fuka10 · May 10, 2014 at 08:08 AM 0
Share

ok first thanks for trying to help me, here is a script

using UnityEngine; using System.Collections;

public class CameraControl : $$anonymous$$onoBehaviour {

 Transform Target;
 double Distance = -10;
 double lift = 1.5;

 // Update is called once per frame
 void Update () {
     transform.position = Target.position;
 }

}

but in unity its showing only this :

alt text

P.s. when i first instaled unity it was normal so it might be setting or something and i tried reinstalling it

unity error.png (43.0 kB)

2 Replies

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

Answer by vexe · May 10, 2014 at 06:31 PM

That's because your variables are non public (private) To make a field visible in the inspector, it has to play nice with Unity's serialization. So you either do:

 public Transform Target;
 public double Distance = -10;
 public double lift = 1.5;

But it's a bad habit to make all fields public, unless you know what you're doing. However; making them private will tell unity not to serialize them unless you markup with [SerializeField], so:

 [SerializeField]
 private Transform Target;
 [SerializeField]
 private double Distance = -10;
 [SerializeField]
 private double lift = 1.5;

Keep in mind, something being visible in the inspector is a side effect to serialization. Which means, if something doesn't serialize, it won't show up in the inspector.

Edit: as suggested above by @JasperFlick, use floats instead of doubles.

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
avatar image
1

Answer by Jasper-Flick · May 10, 2014 at 06:29 PM

Your variables aren't public. You have specified no access modifier, which means they are internal (should be private) by default. Explicitly declare them as public. Also, better use float instead of double, as floats are used everywhere in Unity while doubles aren't.

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 vexe · May 10, 2014 at 06:31 PM 0
Share

Beat me to it :P - +1 For mentioning floats, I had that in $$anonymous$$d but forgot to.

avatar image fafase · May 10, 2014 at 06:58 PM 1
Share

Except that this is wrong, they are not internal by default or they would be accessible from any other scripts in the project, they are private by default.

avatar image Jasper-Flick · May 11, 2014 at 03:23 PM 0
Share

Thanks for the correction, edited. Top level types are internal by default, the rest private.

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

23 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

Related Questions

Reset script variable values automatically? 2 Answers

getting error with code from https://unity3d.com/learn/tutorials/topics/multiplayer-networking/player-health-single-player 0 Answers

3D game kit Ellen / Show Player Input script variables on the inspector, 0 Answers

Trigger respawn point through player variables. 1 Answer

acces variables from other script 2 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