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 LT23Live · Aug 24, 2014 at 12:12 AM · inspectorclasspublic

Inspector not showing my public changes.

im making a mass spawn script and i am trying to set the waves of objects to spawn. In the inspector it only shows Wave1, but not 2, 3, or 4.

I attached the script Can anyone help?

using UnityEngine; using System.Collections; [System.Serializable] //created the following as a class so takes up less space in inspector //Lists the creep then how many creeps in the wave for designer adjust public class CreaturesWave1 { public GameObject enemy1; public int numEnemy1InWave1 = 5; public GameObject enemy2; public int numEnemy2InWave1 = 0; public GameObject enemy3; public int numEnemy3InWave1 = 0; public GameObject enemy4; public int numEnemy4InWave1 = 0; } public class CreaturesWave2 { public GameObject enemy1; public int numEnemy1InWave1 = 5; public GameObject enemy2; public int numEnemy2InWave1 = 0; public GameObject enemy3; public int numEnemy3InWave1 = 0; public GameObject enemy4; public int numEnemy4InWave1 = 0; } public class CreaturesWave3 { public GameObject enemy1; public int numEnemy1InWave1 = 5; public GameObject enemy2; public int numEnemy2InWave1 = 0; public GameObject enemy3; public int numEnemy3InWave1 = 0; public GameObject enemy4; public int numEnemy4InWave1 = 0; } public class CreaturesWave4 { public GameObject enemy1; public int numEnemy1InWave1 = 5; public GameObject enemy2; public int numEnemy2InWave1 = 0; public GameObject enemy3; public int numEnemy3InWave1 = 0; public GameObject enemy4; public int numEnemy4InWave1 = 0; } public class Spawner : MonoBehaviour { public GameObject[] WayPointsLevel1 = new GameObject[5]; //sets the array that holds the waypoints for wave 1 in order as dropped into the inspector public GameObject spawnLoc; //sets up a spawn location where we can use all the creeps when we first start the level public GameObject startPoint; //sets up a staging area that the creep 'pops' to before starting its path //The following creates arrays for each creature public string enemy1Name; public string enemy2Name; public string enemy3Name; public string enemy4Name; private GameObject[] enemy1; private GameObject[] enemy2; private GameObject[] enemy3; private GameObject[] enemy4; //variables created to be used as a counter private int numEnemy1; private int numEnemy2; private int numEnemy3; private int numEnemy4; public float spawnRate = 0.7f; //Instantiates the class so our Spawner class can use it public CreaturesWave1 Wave1; public bool Wave1Enabled; public CreaturesWave2 Wave2; public bool Wave2Enabled; public CreaturesWave3 Wave3; public bool Wave3Enabled; public CreaturesWave4 Wave4; public bool Wave4Enabled; void Start () { Wave1Enabled = true; Wave2Enabled = false; Wave3Enabled = false; Wave4Enabled = false; } // Use this for initialization void Update() { if (Wave1Enabled == true) { //I cache the number so I can iterate without using a property //which would have to be looked up each iteration during CreateCreeps() numEnemy1 = Wave1.numEnemy1InWave1; numEnemy2 = Wave1.numEnemy2InWave1; numEnemy3 = Wave1.numEnemy3InWave1; numEnemy4 = Wave1.numEnemy4InWave1; //There I create "holding" arrays for each creep we are going to make //this way we can activate/deactivate them easily enemy1 = new GameObject[numEnemy1]; enemy2 = new GameObject[numEnemy2]; enemy3 = new GameObject[numEnemy3]; enemy4 = new GameObject[numEnemy4]; //Starts instantiating the creeps, stores them, then deactivates them CreateCreeps(numEnemy1, numEnemy2, numEnemy3, numEnemy4); //Moves creeps to starting area and activates them StartCoroutine(LaunchCreeps(spawnRate, numEnemy1, numEnemy2, numEnemy3, numEnemy4)); } else if (Wave2Enabled == true) { //I cache the number so I can iterate without using a property //which would have to be looked up each iteration during CreateCreeps() numEnemy1 = Wave2.numEnemy1InWave1; numEnemy2 = Wave2.numEnemy2InWave1; numEnemy3 = Wave2.numEnemy3InWave1; numEnemy4 = Wave2.numEnemy4InWave1; //There I create "holding" arrays for each creep we are going to make //this way we can activate/deactivate them easily enemy1 = new GameObject[numEnemy1]; enemy2 = new GameObject[numEnemy2]; enemy3 = new GameObject[numEnemy3]; enemy4 = new GameObject[numEnemy4]; //Starts instantiating the creeps, stores them, then deactivates them CreateCreeps(numEnemy1, numEnemy2, numEnemy3, numEnemy4); //Moves creeps to starting area and activates them StartCoroutine(LaunchCreeps(spawnRate, numEnemy1, numEnemy2, numEnemy3, numEnemy4)); } else if (Wave3Enabled == true) { //I cache the number so I can iterate without using a property //which would have to be looked up each iteration during CreateCreeps() numEnemy1 = Wave3.numEnemy1InWave1; numEnemy2 = Wave3.numEnemy2InWave1; numEnemy3 = Wave3.numEnemy3InWave1; numEnemy4 = Wave3.numEnemy4InWave1; //There I create "holding" arrays for each creep we are going to make //this way we can activate/deactivate them easily enemy1 = new GameObject[numEnemy1]; enemy2 = new GameObject[numEnemy2]; enemy3 = new GameObject[numEnemy3]; enemy4 = new GameObject[numEnemy4]; //Starts instantiating the creeps, stores them, then deactivates them CreateCreeps(numEnemy1, numEnemy2, numEnemy3, numEnemy4); //Moves creeps to starting area and activates them StartCoroutine(LaunchCreeps(spawnRate, numEnemy1, numEnemy2, numEnemy3, numEnemy4)); } else if (Wave4Enabled == true) { //I cache the number so I can iterate without using a property //which would have to be looked up each iteration during CreateCreeps() numEnemy1 = Wave4.numEnemy1InWave1; numEnemy2 = Wave4.numEnemy2InWave1; numEnemy3 = Wave4.numEnemy3InWave1; numEnemy4 = Wave4.numEnemy4InWave1; //There I create "holding" arrays for each creep we are going to make //this way we can activate/deactivate them easily enemy1 = new GameObject[numEnemy1]; enemy2 = new GameObject[numEnemy2]; enemy3 = new GameObject[numEnemy3]; enemy4 = new GameObject[numEnemy4]; //Starts instantiating the creeps, stores them, then deactivates them CreateCreeps(numEnemy1, numEnemy2, numEnemy3, numEnemy4); //Moves creeps to starting area and activates them StartCoroutine(LaunchCreeps(spawnRate, numEnemy1, numEnemy2, numEnemy3, numEnemy4)); } } void CreateCreeps(int Mon1, int Mon2, int Mon3, int Mon4) { //a series of for statements (one per creep type) to spawn the creeps all at once //when the wave loads for(int i = 0; i < Mon1; i++) { GameObject enemy1Creep = Instantiate(Wave1.enemy1, spawnLoc.transform.position, spawnLoc.transform.rotation) as GameObject; enemy1Creep.name = enemy1Name; enemy1[i] = enemy1Creep; enemy1[i].SetActive(false); } for(int i = 0; i < Mon2; i++) { GameObject enemy2Creep = Instantiate(Wave1.enemy2, spawnLoc.transform.position, spawnLoc.transform.rotation) as GameObject; //creates it enemy2Creep.name = enemy2Name; //names it enemy2[i] = enemy2Creep; //stores it in array enemy2[i].SetActive(false); } for(int i = 0; i < Mon3; i++) { GameObject enemy3Creep = Instantiate(Wave1.enemy3, spawnLoc.transform.position, spawnLoc.transform.rotation) as GameObject; enemy3Creep.name = enemy3Name; enemy3[i] = enemy3Creep; enemy3[i].SetActive(false); } for(int i = 0; i < Mon4; i++) { GameObject enemy4Creep = Instantiate(Wave1.enemy4, spawnLoc.transform.position, spawnLoc.transform.rotation) as GameObject; enemy4Creep.name = enemy4Name; enemy4[i] = enemy4Creep; enemy4[i].SetActive(false); } } IEnumerator LaunchCreeps(float spawnRate, int Mon1, int Mon2, int Mon3, int Mon4) { for(int i = 0; i < Mon1; i++) { enemy1[i].SetActive(true); enemy1[i].transform.position = startPoint.transform.position; yield return new WaitForSeconds(spawnRate); } for(int i = 0; i < Mon2; i++) { enemy2[i].SetActive(true); enemy2[i].transform.position = startPoint.transform.position; yield return new WaitForSeconds(spawnRate); } for(int i = 0; i < Mon3; i++) { enemy3[i].SetActive(true); enemy3[i].transform.position = startPoint.transform.position; yield return new WaitForSeconds(spawnRate); } for(int i = 0; i < Mon4; i++) { enemy4[i].SetActive(true); enemy4[i].transform.position = startPoint.transform.position; yield return new WaitForSeconds(spawnRate); } } }

Comment
Add comment · Show 1
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 Kirbyrawr · Aug 24, 2014 at 02:49 AM 0
Share

Hi sir, you should reformat your code, also i suggest you to not put the whole code since it's a mess, post only the variables maybe.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kirbyrawr · Aug 24, 2014 at 02:49 AM

You should put [System.Serializable] on the top of ALL the classes like this:

 [System.Serializable]
 public class CreaturesWave1
 
 [System.Serializable]
 public class CreaturesWave2
 
 [System.Serializable]
 public class CreaturesWave3
 
 [System.Serializable]
 public class CreaturesWave4

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 LT23Live · Aug 25, 2014 at 01:01 AM 1
Share

Thank you!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Public class used in another class (C#) 1 Answer

[SOLVED]How to use attributes from array of custom class instances? 1 Answer

Inspector button for custom class 1 Answer

Public string/GameObject not in inspector 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