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 JJNCreator · Jul 20, 2012 at 02:37 PM · loadresourcesfolderitemgenerator

Resources.Load problem

hey guys. i have an item generator script and a resources folder with item icons. I use these for my Inventory and Loot windows. However, I'm not getting Resources.Load in the Resources functions. Here's the item script:

using UnityEngine;

public static class ItemGenerator { public const int BASE_MELEE_RANGE = 1; public const int BASE_RANGED_RANGE = 5;

private const string WEAPON_PATH = "Icons/Weapons/Melee/"; private const string POTION_PATH = "Icons/Potions/Health/";

public static Item CreateItem() { Item item = CreateWeapon();

// private string _name; item.Value = Random.Range(1, 101); item.Rare = RarityTypes.Common; item.MaxDurability = Random.Range(50, 61); item.CurDurability = item.MaxDurability;

return item; }

private static Weapon CreateWeapon() { Weapon weapon = CreateMeleeWeapon();

return weapon; }

private static Weapon CreateMeleeWeapon() { Weapon meleeWeapon = new Weapon();

string[] itemNames = new string[3]; itemNames[0] = "Blue Sword"; itemNames[1] = "Health Soda"; itemNames[2] = "Max Health Soda";

meleeWeapon.Name = itemNames [Random.Range(0, itemNames.Length)];

meleeWeapon.MaxDamage = Random.Range(5, 11); meleeWeapon.DamageVariance = Random.Range(.2f, .76f); meleeWeapon.TypeOfDamage = DamageType.Slash; meleeWeapon.MaxRange = BASE_MELEE_RANGE;

// meleeWeapon.Icon = Resources.load(WEAPON_PATH + POTION_PATH + meleeWeapon.Name) as Texture2D;

return meleeWeapon; }

}

public enum ItemType { Armor, Weapon, Potion, Clothing }

Do you have any suggestions? Thanks

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
0
Best Answer

Answer by whydoidoit · Jul 20, 2012 at 02:41 PM

I imagine that you have created a class or script with the name Resources which is hiding the real Unity one. Rename that and it should work.

The correct capitalization is Resources.Load by the way.

Comment
Add comment · Show 4 · 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 JJNCreator · Jul 20, 2012 at 03:06 PM 0
Share

I just looked through all my current scripts. None of them had Resources. However, someone on this website said getting this function involves accessing the hardrive. Do you think that's true?

avatar image whydoidoit · Jul 20, 2012 at 03:08 PM 0
Share

Well using it reads data from the compiled resources. Not sure what you mean? What isn't happening? It won't compile or it doesn't load your resources?

avatar image JJNCreator · Jul 20, 2012 at 03:21 PM 0
Share

It's not compiling. I type in "Load" in $$anonymous$$onoDevelop and it's not there in the functions list for Resources

avatar image JJNCreator · Jul 20, 2012 at 04:51 PM 0
Share

This tutorial I'm following might help:

http://www.youtube.com/watch?v=9v8xXzbOcCo

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Subfolders with Resources.Load not working 2 Answers

AssetDatabase current folder? 2 Answers

Dynamically load AudioClip during runtime 1 Answer

Resources.Load performance specific question 1 Answer

error CS0117: `Resources' does not contain a definition for `Load' 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