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 Albert-han · Jul 05, 2014 at 06:52 AM · publicnotupshowing

public not showing up

Anybody has an idea why my public not showing up inspector.My script:

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public class WeaponManager : MonoBehaviour {
     public List<Gun> Weapons = new List<Gun>();
     public List<string> WeaponNames = new List<string>();
     public int CurWeapon;
     public static WeaponManager Instance;
     // Use this for initialization
     void Start () {
         Instance = this;
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     void OnGUI()
     {
         CurWeapon = GUILayout.SelectionGrid (CurWeapon, WeaponNames.ToArray(), 4);
     }
 
     public static void FindWeapon(string Name)
     {
         foreach (Gun Gu in Instance.Weapons) 
         {
             if(Name == Gu.Name)
                 return Gu;
         }
         return null;
     }
 }
 
Comment
Add comment · Show 5
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 Albert-han · Jul 05, 2014 at 07:01 AM 0
Share

Another public that i put in my other script is also not showing up.

avatar image Kiwasi · Jul 05, 2014 at 07:26 AM 0
Share

Which public is not showing up? Is it all of them, or just some. I know there are certain types that Unity doesn't support assigning in the inspector.

Its also possible that your script hasn't refreshed since your last update.

avatar image NoseKills · Jul 05, 2014 at 08:31 AM 0
Share

^^ Also that static Weapon$$anonymous$$anager won't show in the inspector because all prefabs are essentially instances, so it wouldn't make sense to be able to assign statics in any spcific prefab.

avatar image fafase · Jul 05, 2014 at 09:29 AM 0
Share

Only curWeapon is meant to show up. Statics don't, neither do lists in normal mode.

avatar image AlkisFortuneFish · Jul 05, 2014 at 11:35 AM 0
Share

@fafase

What do you mean that lists don't? Lists of serializable types do show up.

1 Reply

· Add your reply
  • Sort: 
avatar image
8
Best Answer Wiki

Answer by AlkisFortuneFish · Jul 05, 2014 at 11:34 AM

The inspector only shows instance fields that it can serialize.

Pasting from the recent Unity Serialization blog post:

What does a field of my script need to be in order to be serialized?

  • Be public, or have [SerializeField] attribute

  • Not be static

  • Not be const

  • Not be readonly

  • The fieldtype needs to be of a type that we can serialize.

Which fieldtypes can we serialize?

  • Custom non abstract classes with [Serializable] attribute.

  • Custom structs with [Serializable] attribute. (new in Unity4.5)

  • References to objects that derive from UntiyEngine.Object

  • Primitive data types (int,float,double,bool,string,etc)

  • Array of a fieldtype we can serialize

  • List of a fieldtype we can serialize

In your case, the serializable fields are the WeaponNames list and CurWeapon. I presume that you want your Weapons list to be shown as well but to do that you need to show us your Gun class. I suspect that it is not a serializable class or a class deriving from UnityEngine.Object through ScriptableObject or MonoBehaviour.

If it is a serializable data class, the serialization system will serialize the contents of your objects into WeaponManager and display the members of each instance in your list.

alt text

If it is a ScriptableObject class, a MonoBehaviour class or anything else deriving from Object, you will see a list of Object references instead.

alt text


monobehaviour.png (11.0 kB)
serializabledataclass.png (13.8 kB)
Comment
Add comment · Show 1 · 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 AlkisFortuneFish · Jul 08, 2014 at 01:17 PM 0
Share

If this answer helped you, please click accept. Otherwise, please let us know that it didn't. It's rude to ask for people's help, have them spend their time to try and help you and then disappear.

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

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

Related Questions

Build Setting Menu NOT Showing Up Right! 0 Answers

Scripts not showing in Monodevelop 1 Answer

RevMob iOS ads not showing 1 Answer

my admob banner not showing, 1 Answer

Animation window not showing list of animations, even if i click on the object 9 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