Answer the question
In order to leave comments, you need to log in
How to add information from another script to the list?
Sorry if this is a stupid question, but I couldn't find an answer on the internet.
But how to run new MyInfo("name1") Inside another
File1Scr script
public class MyInfo
{
string Name;
public Card(string name)
{
Name = name;
}
}
// Работает
list.Add(new MyInfo("name1"));
File1Scr MyInfo;
// Не работает
list.Add(new MyInfo("name1"));
'MyInfo' does not contain a constructor that takes 1 arguments
Answer the question
In order to leave comments, you need to log in
You need a link to an object.
In a unit, an analogue of an object is a component, and you need to get it, for example, drag it into the corresponding field of the final object. To define access to a field, access modifiers are used, you need public. In the programming society, it is customary not to use public fields, but to give access to their VALUES through methods, for example:
public string getName()
{
return Name;
}
public void setName( string Value)
{
Name=Value;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question