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 user-3230 (google) · Jun 25, 2010 at 05:53 PM · guiinventory

Scripting help (sending messages?)

ok so i want to make an inventory for my game.

i want it to open when i press the mouse on the inventory picture so i added the script

function onMouseDown ()

i need the function to open the other picture of the bag grid

how would i be able to make this happen.

and if some one could tell me how to set up a grid that i can place clickable abjects too and how to make the clicked button to send a message to a receiver ex.

press robe - robe icon goes into the armor window - and gives the empty the message to add new object robe and destroy other object that was on there before (replace them)- and that send a message to stats saying to add more mana+ health +armor+spell power.

thank you

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
2

Answer by qJake · Jun 25, 2010 at 06:44 PM

Try not to ask more than one question in a single post, and try not to ask such a broad question in the future. Regardless, I'll do my best to point you in the right direction.

First, you can create a grid of buttons using this function:

http://unity3d.com/support/documentation/ScriptReference/GUI.SelectionGrid.html

You can make it appear and disappear using a script like this (but not exactly this, don't copy and paste it):

bool inventoryVisible = false;

void OnMouseDown() { inventoryVisible = !inventoryVisible; }

void OnGUI() { if(inventoryVisible) { // GUI Selection Grid Code Here } }

I can't help you with sending messages to other scripts, simply because you have provided little to no detail about your specific setup, and since there are many different ways of calling functions of other objects, I can't be specific. I can, however, link you to this page, which describes in detail how to access other scripts on other game objects:

http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

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 user-3230 (google) · Jun 25, 2010 at 07:57 PM 0
Share

could you make one that i can copy and paste? Im really bad at scripting and i ordered a text book for java scripting but it wont come till 2 weeks

avatar image qJake · Jun 25, 2010 at 08:55 PM 1
Share

Nope, I won't. This isn't even real code, it's just kind of an "overview" of how you could do it. You need to code this yourself, we won't code for you here.

avatar image MrLolEthan · Oct 14, 2012 at 10:59 AM 0
Share

You cant just copy and paste something as advanced as an inventory system. You need to code it yourself to make it work with YOUR game setup, that most likely is too hard to explain to others and your gonna wanna link to other scripts and gameObjects. You will want to maintain it and update it yourself too.

avatar image MrLolEthan · Oct 14, 2012 at 11:03 AM 0
Share

Btw you need a Unity based text book because JavaScript is much different from UnityScript (thats what unity's version of JavaScript is called). Now your JavaScript book will help with some stuff like declaring functions and that. If you want to learn JavaScript (NOT UnityScript) go here: www.codeacademy.com/ <- they have helpful JavaScript tutorials which will help with basic unity things like variables, function, and for loops.

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

1 Person is following this question.

avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Setting Scroll View Width GUILayout 1 Answer

Hotbar and item pickups? 1 Answer

Script Not Working 0 Answers

Adding Item object to Inventory List 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