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 PemuG · Jul 22, 2013 at 05:29 PM · inventoryinventory system

Common script

Hey! I have a problem - I create script (Inventory), this script is included to axe and pickaxe. My problem is that axe and pickaxe "reads" the same values, so when pickaxe have a slot 2, axe have a slot 2 too. My english is a modest, but I think you understand my problem ;)

Thanks in advance ;)

This is a my script (variables and comments are in Polish):

   //miejsce slotów
 private var slot : Rect = new Rect(-155, -245, 40, 30);
 private var slot2 : Rect = new Rect(-100, -250, 40, 30);
   //inne
 var mozna : boolean = false;
 var Tekst : GUIText;
 var wyl : boolean = false;
 var tekstura : GUITexture;
   //sloty zajęte
 private var slotz : boolean = false;
 private var slotz2 : boolean = false;
 private var slotz3 : boolean = false;
 private var slotz4 : boolean = false;
 private var slotz5 : boolean = false;
 private var slotz6 : boolean = false;
 
 
 
   private function Update(){
   if(Input.GetMouseButtonDown(1)&&mozna==false&&BlokowanieInwentarz.inwentarz==true){
 mozna=true;
 BlokowanieInwentarz.mozna2=false;
 Tekst.enabled=true;
 }
   if(mozna==true&&Input.GetButtonDown("1")&&slotz==false){
 tekstura.pixelInset = slot;
 wyl=true;
 slotz=true;
 slotz2=false;
 }
   if(mozna==true&&Input.GetButtonDown("2")&&slotz2==false){
 slotz=false;
 tekstura.pixelInset = slot2;
 wyl=true;
 slotz2=true;
 }
   if(wyl){
 Tekst.enabled=false;
 BlokowanieInwentarz.mozna2=true;
 mozna=false;
 wyl=false;
 }
 }
Comment
Add comment · Show 5
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 Peter G · Jul 22, 2013 at 05:35 PM 2
Share

Could you share some of your script with us? :)

avatar image Benproductions1 · Jul 23, 2013 at 02:15 AM 0
Share

Please add indentation. It's impossible to read...

avatar image Graham-Dunnett ♦♦ · Jul 23, 2013 at 11:02 AM 0
Share

I removed the unity and unityanswers tags from your post. Neither are needed since this is unityanswers, a site all about unity.

avatar image PemuG · Jul 23, 2013 at 11:04 AM 0
Share

Ok, thanks

avatar image PemuG · Jul 23, 2013 at 12:44 PM 0
Share

Ok, thanks! But I but I do it in a different way ;)

Thanks for help. I hope this I finish.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by FrimaMickD · Jul 23, 2013 at 12:18 PM

I think your problem is having the Input logic in the class... It's kinda difficult to read but from what I get, when you press the button "2", the pixel inset of the texture you reference in your class will change to slot2. And to slot1 if you press the "1" button.

The fact that it does for the 2 objects is normal then.

If you want to do it but only for 1 of your object (the pickaxe for example), you have to either remove the Input logic from that class and add a kind of SetSlot() functionnality to that script so that when you press button "2" you only have the "selected" tool doing the SetSlot() function.

Here is some pseudo code:

 selectedWeapon = "pickaxe";
 if(Input.GetButtonDown("2"))
 {
     selectedWeapon.SetSlot(2);
 }

I hope this will help you a little and good luck!

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 PemuG · Jul 23, 2013 at 12:36 PM 0
Share

Ok, thanks! But I but I do it in a different way ;)

Thanks for help. I hope this I finish.

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

19 People are following this question.

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

Related Questions

A way to implement "Use" of item in game. A way to serialize object with method from other script maybe? 2 Answers

Items Changing Player Stats, Backpack increasing Inventory Size 1 Answer

How can I transfer the item's image in inventory UI to the next scene?,How can I keep and transfer the image of items in the inventory in different scenes? 0 Answers

Button in GUI BeginScrollView problem 0 Answers

Inventory question 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