eimiieee
eimiieee
CC#
Created by eimiieee on 2/18/2023 in #help
❔ Question about cache
Hello, I have the following code.
private Class1 class1;
private Class2 class2;

private void Start(){
class1 = Class1.Instance;
class2 = Class2.Instance;
}

private void Update()
{
UpdateState();
}

private void UpdateState()
{
Helpers(class1);
// etc, removed for breiviety
}

private void Helpers(Class1 class1);
{
if(class1.something > 0)
{
// Do stuff
}
}
private Class1 class1;
private Class2 class2;

private void Start(){
class1 = Class1.Instance;
class2 = Class2.Instance;
}

private void Update()
{
UpdateState();
}

private void UpdateState()
{
Helpers(class1);
// etc, removed for breiviety
}

private void Helpers(Class1 class1);
{
if(class1.something > 0)
{
// Do stuff
}
}
I was reccomended to cache Class1 inside the helpers method as such var myClass = class1.something; However, my question is if that is necessary since i already cached the class in Start() and then pass that in the helpers parameters I hope my question was understandable 🙂
3 replies
CC#
Created by eimiieee on 1/30/2023 in #help
Accessing a table in a list of subclasses (unity)
Hello, i'm trying to change a value of a table during runtime. I have a unity object called manager that is the main, which in turn contains a class called unit, unit contains a list with costumes, along with all the options in a table, where of inside there is a simple bool which i'd like to change from ALLOWED to DISABLED and vice versa, however when i try to access this during runtime it tells me that the object I try access doesn't exit even if i know it's there and, simplified it's something like this
var example = Manager.unit.costumeMap[0];
example.costumeTable.usingType = Manager.costumeTable.USING_TYPE.ALLOWED;
var example = Manager.unit.costumeMap[0];
example.costumeTable.usingType = Manager.costumeTable.USING_TYPE.ALLOWED;
What I doing wrong?
11 replies