Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 DarthPork · Jun 24, 2016 at 04:58 AM · prefabarrayrandomize

Question (or recommendation) on my data structure for getting Prefabs into an array (as gameobjects?)

thanks in advance.... synopsis: Little rpg card game / dungeon crawl with random encounters Currently, this is how my setup loads: I load all my prefab cards (EVERY encounter card I have) into an Object[] and pick one at random to instantiate. Everything's hunky dory with that and 100% random. Now my issue is, I'd like to go back and put some weight to what's instantiate on the board (if it's the first level, put low level/the 'common' cards out there the majority of the time) but my rarity for the cards is listed in a script attached to each prefab. Since these are "objects" and not GameObjects, I don't see any way of calling these scripts and semi-stuck with 100% randomness with the current setup. My code is as simple as var prefabArray : Object[]; Start(){ prefabArray = Resources.LoadAll("Prefabs") } // plus some code to pick one at random and place it on the board My question(s) is 1) is there actually a way to get the scripts on an 'object' somehow? that would be excellent and easiest solution 2) if not - is there an easy way to cast them to GameObjects from an Object array? (if i could do some sort of cycling through all the prefabs and check the rarity, that would be fantastic - sounds like I can only do this with gameobjects though? I'm not even sure that's true since nothing is Instantiated at this point) Otherwise, the only solution I can think of is to restructure my folder structure (instead of just having an "enemy" folder, put a folder for each rarity) (current) Prefabs -- Cards -- ( 6 folders for various card types) DONE. to something like -- Prefabs -- Cards -- Enemies -- EnemiesCommon -- EnemiesUncommon -- rare, legenary, super duper awesome sauce, so on, so on. Then repeat for the other card types. Basically tons of folders that I could do a Resource.load for specific folders (so I count.... 8 card types, 6 rarities for each, then an array for each combination..... carry the 1.... Answer: A shit load. Final answer... no lifeline) Sounds like a pain in the ass, would love a simple solution.

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

0 Replies

· Add your reply
  • Sort: 

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

Array of prefabs 0 Answers

Randomize texture within prefab 0 Answers

Assigning Instantiated Tiles to Array 1 Answer

Problem with instantiating prefab object 0 Answers

OverlapSphere for parallel arrays 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