How to give objects different prices?

Hi, First of all I’m a total noob in unity so please don’t make it to hard for me :slight_smile:

I have a little shop with different products and i want to give each product a different price, the problem is that i don’t really know how to do this.
At this moment i do it like this:
`var price : float = 0.0;

function Start()
{
}
function Update ()
{
if(Input.GetKeyUp (KeyCode.Mouse0))
%|-1428240678_2|%
price += 1;
}

}

function OnGUI()
{
GUI.Box(new Rect(10, 50,80, 30), “price:” + price.ToString(“0”));
}`

with this script i can click everywhere and the price will go +1…

hope you have enough information to help me.

I’ll try to help you with a solution I think fits for your problem, but not sure if this is what you are looking for.

Lets say you have 3 items in your shop : an apple, a banana, and a chocolat bar . What I believe you want to accomplish is that for example your apple costs 0.5 , your banana 1 and your chocolate bar 1.2, is that correct ?

If that is the case I would create one script that you apply to all your items in your shop.
i’ll give you an example of what I would do but it’s going to be in cSharp… but i’m sure you can translate it into javaScript since its only going to be one line of code.

I’ll create a new Script called : ItemScript

in ItemScript I initilize a public float called price ( public float price ; in cSharp )
once the script is created you can apply that script to each of your items and give each of them a price to your liking in the inspector without interfering with the other prices of your items.