Par ex :
Code : Tout sélectionner
public string NomVariableInt = a;
public int ""+a;
Merci d'avance !
Code : Tout sélectionner
public string NomVariableInt = a;
public int ""+a;
c'est le premier truc qui m'est venu à l'esprit. Maintenant @General_Bright, comme tu n'en dit pas plus sur le pourquoi du comment de cette approche, difficile de bien conseiller
Code : Tout sélectionner
Dictionary<string, int> d = new Dictionary<string, int>();
d.Add("var1", 1234);
d.Add( nomVariableInt , 2345);
d.Add( nomVariableInt+"e" , valInt);
etc...
Code : Tout sélectionner
public string variableName = "";
public UnityEngine.Object target = null;
// Get the property of the variable on the type of the script
public MemberInfo GetProperty()
{
if (target != null)
{
MemberInfo propName = target.GetType().GetField(variableName);
if (propName != null)
{
return propName;
}
propName = target.GetType().GetProperty(variableName);
if (propName != null)
{
return propName;
}
}
return null;
}
// Return an object that contain the value of the variable. You must cast the result to use it as a given type
public System.Object GetPropertyValue()
{
System.Object value = null;
MemberInfo property = GetProperty();
if (property != null)
{
try
{
if (property is FieldInfo)
{
value = (property as FieldInfo).GetValue(
target // So we specify who owns the object
);
}
else if (property is PropertyInfo)
{
value = (property as PropertyInfo).GetValue(
target, // So we specify who owns the object
null
);
}
}
catch (Exception e) { }
}
return value;
}
Si tu expliques ton souci, on aura sans doute une solution plus facile à te proposer.General_Bright a écrit : ↑24 Sep 2017 15:51Merci beaucoup de votre aide et avoir pris la peine de me lire mais sa devient beaucoup trop complexe pour moi ! ^^
Donc je vais laisser tomber (J'ai d'autres projets) ,
Encore merci et désoler de vous avoir fait perde votre temps.