Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Jason B · Aug 16, 2011 at 04:18 AM · c#gameobjecteditorarrayinspector

Can a GameObject inside of an array be made "accessible" from the editor?

Right now I'm developing a game that requires enemies to spawn at specific times.

To simplify this process, I have sort of a "spawning manifest", which contains 3 different public arrays. The first lets me choose a prefab, the second lets me pick what time each enemy is spawned, and the third tells it where to spawn.

However, enemies of all different types will need to be spawned (and they have numerous variables, such as firing rate, movement speed, etc.). Will I need to make a prefab of every tiny variation, or is there some way to access (in the editor) a GameObject's components/values while it is displayed inside of an array?

For instance, in the Inspector I unfold the "Enemies" array, add one to the list, and I can see all of its editable values much like if I selected the prefab directly?

If not, this doesn't bode well and I'll have to scrap my entire spawning system, and unfortunately I don't know what else to do in its stead except place every enemy by hand.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by assaf.mendelson · Aug 16, 2011 at 05:16 AM

The easiest way to do this is to create a custom inspector. you should start with: http://unity3d.com/support/documentation/Components/gui-ExtendingEditor.html here is an example of building custom arrays: http://answers.unity3d.com/questions/26207/how-can-i-recreate-the-array-inspector-element-for.html what you would need to do is add some stuff to expand each array element in a similar manner.

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 Jason B · Aug 16, 2011 at 06:29 AM 0
Share

I've been scared of trying to extend the editor so far. :P It seems fairly complicated. I'll consider it though.

avatar image
0

Answer by Waz · Aug 16, 2011 at 05:26 AM

Sounds like your structure dependencies are backwards, since you don't want the variables in the prefab GameObject, yet you have them there. I would suggest that you move those variables you mention to an EnemyData class that is just a structure of the variables. You then have a single array of these. When an object is spawned, the prefab is instantiated, and a data variable that replaces those variables is set to the one in the array.

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 Jason B · Aug 16, 2011 at 06:27 AM 0
Share

Yeah, I'm still trying to learn as I go and I'm finding more and more that the less I plan, the more stumbling blocks I hit on the way, so I'm trying to make everything as easily modifiable as possible. I thought I was being proactive for my spawner but it clearly has its shortco$$anonymous$$gs. I suppose I could do what you say, and then use Send$$anonymous$$essage to the instantiated objects to inform their statistics (I have to use something general because all the different enemy types are so different that they use different AI scripts, though I could give them all similarly-named functions so they can receive generic Send$$anonymous$$essage orders). Not sure if I'm muddling your suggestion though.

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

Custom Inspector: Targets & GameObjects 1 Answer

Insert new custom class element with _default_ values to a SerializedProperty array? 1 Answer

Prefab not loading in data from Inspector 1 Answer

Can one specify the parent of a gameobject in an array? 2 Answers

How to set to game objects's position from 2 different game objects arrays equal to each other? 0 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