Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 rjdiogo · Jul 20, 2015 at 04:42 AM · arrayinspectorshow

Arrays don't show up on inspector

I have these two classes and both of them don't show up the arrays on inspector. Does someone can help me out why?

public class TowerSystemManager : MonoBehaviour { public LevelTowerSystemController[] towerType = new LevelTowerSystemController[ 4 ]; }

 [System.Serializable]
 public class LevelTowerSystemController : MonoBehaviour 
 {
     public GameObject[] towerLevel = new GameObject[ 2 ];
      
     public GameObject this[ int i ]
     {
         get
         {
             return towerLevel[ i ];
         }
         set
         {
             towerLevel[ i ] = value;
         }
     }
 
     public int Length
     {
         get
         {
             return towerLevel.Length;
         }
     }
 }
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 Owen-Reynolds · Jul 20, 2015 at 04:58 AM 0
Share

$$anonymous$$aybe start with something simpler? $$anonymous$$onobehavior scripts just show up in the Inspector for the object. They wouldn't be in an array -- they're the whole component. You also wouldn't normally need to put [sys.serialize] in front of them.

towerLevel should be appearing as an array. But you don't normally assign (`new`) anything to a public array (I don't think what you have is even legal.) You set the size and items directly in the Inspectors.

And, those getters and setters ... they don't do anything except impress hard-core Java-ists. If they're giving you the slightest trouble, get rid of them.

avatar image _Gkxd · Jul 20, 2015 at 05:19 AM 0
Share

Assu$$anonymous$$g that your script is "TowerSystem$$anonymous$$anager.cs" and not "LevelTowerSystemController.cs," I would make LevelTowerSystemController its own class rather than a child class of $$anonymous$$onobehaviour (though this might not be the issue).

I don't think having two classes extending $$anonymous$$onobehaviour in the same script file is a good idea.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by game-dev333 · Jul 20, 2015 at 06:26 AM

Create two different scripts 1)TowerSystemManager.cs

 using UnityEngine;
 using System.Collections;
 
 public class TowerSystemManager : MonoBehaviour
 {
 
     public LevelTowerSystemController[] towerType;
 }

2) LevelTowerSystemController.cs

 using UnityEngine;
 using System.Collections;
 
 [System.Serializable]
 public class LevelTowerSystemController : TowerSystemManager{
     public GameObject[] towerLevel = new GameObject[ 2 ];
     
     public GameObject this [int i] {
         get {
             return towerLevel [i];
         }
         set {
             towerLevel [i] = value;
         }
     }
     
     public int Length {
         get {
             return towerLevel.Length;
         }
     }
 }

showed me this on inspector alt text


b.png (20.1 kB)
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.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Renaming Inspector 2D Array Element 0 , Element 1 1 Answer

See MonoScript's attributes in the inspector (when it is in an array) 0 Answers

How to change the way the inspector shows variables Javascript 1 Answer

Displaying public variables in the inspector 2 Answers

Keep values in inspector while changing variable name 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