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 zedseven · Jul 14, 2015 at 02:01 PM · c#listsclasses

Class lists not entirely working

I have two classes as well as my main script, and I'm putting the classes into lists to store information about weather types. The problem is, only one of them ever shows up as a list. I have tried switching the order around, and it is only ever the first of the two that gets shown. I get all kinds of errors when working on the other one, and I'm not sure about what to do to fix it.

My code (I removed the irrelevant stuff):

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 [System.Serializable]
 
 public class RainTypes
 {
     public Object rainPrefab;
     public Color fogColour;
     public float fogStart;
     public float fogEnd;
     public Color ambientLight;
 }
 
 public class WindZoneTypes
 {
     public float windMain;
     public float windTurbulence;
     public float windPulseMagnitude;
     public float windPulseFrequency;
 }
     
 
 public class WeatherManager : MonoBehaviour
 {
     public List<RainTypes> rainTypes = new List<RainTypes>();
     public List<WindZoneTypes> windTypes = new List<WindZoneTypes>();
 }

Thank you for your time,

zedseven

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 Bonfire-Boy · Jul 14, 2015 at 02:36 PM 1
Share

Looking at the code I think what you're missing may be the fact that "[System.Serializable]" only applies to the class that immediately follows it. So add it before the second class definition too, and you should be able to see the elements of both when you have public instances visible in the Inspector.

But I may be missing the point of the question - it really isn't clear what you mean by things "not showing up in a list". If you mean the list(s) you create on lines 25-26, then from what you've posted it doesn't look like you put anything into those lists, so naturally nothing will show up in them!

avatar image zedseven · Jul 14, 2015 at 03:26 PM 0
Share

That was absolutely what I was looking for. I just tested it, and it works perfectly now! Thank you very much, Bonfire Boy! By the way, I am adding things into the lists in the inspector, but I meant that the lists themselves weren't showing up.

Thank you again, zedseven

1 Reply

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

Answer by LawgiverSS2 · Jul 14, 2015 at 04:32 PM

Add [System.Serializable] before public class WindZoneTypes.

 [System.Serializable]
 public class RainTypes
 {
     public Object rainPrefab;
     public Color fogColour;
     public float fogStart;
     public float fogEnd;
     public Color ambientLight;
 }
 
 [System.Serializable] 
 public class WindZoneTypes
 {
     public float windMain;
     public float windTurbulence;
     public float windPulseMagnitude;
     public float windPulseFrequency;
 }


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 Bonfire-Boy · Jul 14, 2015 at 05:01 PM 0
Share

Good spot!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to access individual class elements, that has an array, that is in a list for c# 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to carry List's and Vector3's to other classes? Interfaces don't work? 4 Answers

Access list storing custom class variables from another script 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