name int with a string

Hello all,

I have looked around but i cant seem to find the answer so i figured ill just go and ask and hopefully someone can help me.
So im getting some objects with tags and put them in an array pretty normal, but each object will have a set of variables i want to get with them and i want to name those variables after the object it is related to.

normally i call a float like this:

float name = 1,0f;

but i want to do it a bit differently:

string s =  GameObject.name + "Triangle";
float s = 10,0f;

so this should result in the float being CubeTriangle = 10,0f

I think Zodiarc’s answer is heading in the right direction and will work for this case.
But if you want multiple variables to be part of one object, then you should simply create an object.

public class GameObjectData
{
     public GameObject gameObject;
     public float FloatData;
     public string Name;
}

then you can do simply create your new obj based on your new class:

var newObj = new GameObjectData() 
{ 
     gameObject = GameObject,
     FloatData = 10.0f,
     Name = GameObject.name + "Triangle"
};

and u can access and change fields/properties on this object like so:

newObj.Name
newObj.FloatData

This is basic C#

If I understand you correctly you want make variable names dynamically? Why would you want to do that? That’s plain horrible programming and I’m not aware that it’s possible in C#.

If you really insist on it, you could youse a Dictionary:

Dictionary<string, float> namedFloats = new Dictionary<string, float>();
namedFloats.Add(GameObject.name + "Triangle", 10.0f);

because I want to make it modular, i don’t know how many objects the costumer wants and he wants to be able to add them himself so i want the variables we need with each object to be generated if a new 1 is added.
It is a bit of a weird way of doing things but there is a good reason for it, my main question is it possible without going the dictionary route?