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 golddevrush · Dec 13, 2014 at 11:15 AM · spriteresourcesglobal variables

how to: make global variable

hi, i am newbie in unity. before i use vb.net. in vb.net we can create a module just for containing our global variables that can be used in all forms. can i achieve that feature in unity?

the real problem is : i have import some sprites in "assests/resources". i have used them in making sprite in the scene. but i need the "sprite" game object to return some value from comparing its sprite with the sprites in "assets/resources". anyone can help?

Comment
Add comment · Show 3
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 Qasem2014 · Dec 13, 2014 at 12:20 PM 0
Share

i think your variable should be static to get effect from other scripts :)

avatar image pako · Dec 13, 2014 at 12:46 PM 0
Share

There's nothing that you can do in vb.net that you can't do in Unity if you can program in C# or Javascript!

You are not explaining your problem well. For instance, with the function:

 gameobject.GetInstanceID

...you can get the instance id of a GameObject, and is always guaranteed to be unique. However, it may not be useful in your case, because you can't use it to compare with anything in assets/resources.

So, why exactly do you want to compare a GameObject instance, with something in assets/resources?

avatar image golddevrush · Dec 16, 2014 at 01:19 PM 0
Share

all right, i just use array to contain all my sprite in resources folder. and have done the advice from Qasem2014. thx alot.

NB: i just try to make candy-crush-like game to start my "game developer career" :)

2 Replies

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

Answer by Grim_Darknight · Dec 13, 2014 at 09:29 PM

I don't know what specific variable you are dealing with but I will use an integer as an example called number.

 using .....
 
 
 Class xxxx : Monobehavior
 {
    public static int number = 0;
 
    Awake()
    {}
 }


Comment
Add comment · 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
0

Answer by Ericool · Dec 14, 2014 at 01:49 AM

make a script for example SpriteMgr :

inside put a getter like that :

   public Sprite[] instance{get;private set;}

then from another class just get an instance of that script like that : private SpriteMgr spriteReference = new SpriteMgr();

private void Awake(){ if( blabla == spriteReference.instance.something){ do something... } }

Comment
Add comment · 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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Accessing 4.6 GUI build-in sprites in C# 0 Answers

Loading Addressable Sprites using their Address 0 Answers

Sprite obstruction transparent area 1 Answer

How do I change the draw rectangle of a sprite? 0 Answers

Resources.Load("sprite") returning nil 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