What is the proper way to call a function outside the class. The example code here would give the “unknown identifier” error.
Class UnitInfo{
function DemoOne(){
Demo2();
}
}
function Demo2(){
}
After reading Yoerick answer, I did some testing. And found out that using GetComponent I could call a function that was not in a custom class. I will not be using this methods myself, as for my project I can work around the need by working outside the class. This strikes me as bad practice, but it is possible.
var test : someScript; //Name of the script itself
function Start(){
test = GetComponent(someScript);
for (var i : int = 0; i < 9; i++){
Units *= new UnitInfo();*
Units_.Init( departmentSlots*, i, test );
}*_
}
class UnitInfo{
function Init(type : int, slotNum : int, test : operatorScript){
test.Test();
}
}
function Test(){
Debug.Log(“Test Called by class”);
}