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
1
Question by moghes · Jun 10, 2013 at 02:52 PM · arraysceneinspectorlevelscustom class

Set Level inquiry/data from the inspector

I am planning of a puzzle game, where lets say there are 50 leves (just like IQ games) but I want to have a single Scene for all 50 levels and of course designing 50 scenes is not the way.

since all levels are almost similar and vary only in some data, I want to write a class named "Level" and in the main controller script have an array of Levels where I can specify all the Level details just from the inspector.

I don't know how this is possible since the built in array is visible in the inspector, while most of other collections don't.

Mainly I need to have an array of custom class, where the class and its public variables appear in the inpector.

I have created a tree in the inspector of how I want it to be(of course its been modified in photoshop), check the picture and any other solution would really help.alt text

example.jpg (34.8 kB)
Comment
Add comment
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

1 Reply

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

Answer by Bunny83 · Jun 10, 2013 at 03:05 PM

Just create a class like this:

 [System.Serializable]
 public class Level
 {
     public string name;
     public int[] columns;
     public Camera secondaryCamera;
 }

Note: If the first variable in the class is a string, the inspector will show this string instead of the "Element 0" thing.

Just as a little warning: If your Level class is truly the same for all levels this should work pretty well but watch out, if you change something in the Level class it might break all the already setup data.

50 is quite a bit, you might just want to use MonoBehaviour components instead:

 public class Level : MonoBehaviour
 {
     public string name;
     public int[] columns;
     public Camera secondaryCamera;
 }

And attach one for each level. You can attach all to the same GameObject or add them to empty GameObjects. One script per GO is usually the safest way. This way you could even save them as individual prefabs

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 moghes · Jun 10, 2013 at 03:26 PM 0
Share

thank you a lot :) just let me try

avatar image moghes · Jun 10, 2013 at 03:35 PM 0
Share

well this information I just needed, thanks again

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

15 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

Related Questions

[solved] How to edit an array of custom classes in the Inspector 1 Answer

How to show an array of custom objects in Inspector? 2 Answers

Serialized property and custom class 1 Answer

Fade In each level 1 Answer

Public Array with a class not showing in Inspcetor 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