unity3d - Why my C# code is causing a -
unity3d - Why my C# code is causing a -
this code giving stack overflow happens half time , have no thought why it's doing it. seen happens coms(topcom, etc) in mass of numbers around 5+ stack overflows.
public bool getconnected(int d) { if (topcom.connection != null) { if (d != topcom.connection.id) { if (topcom.connection.id == 0) { homecoming true; } else if (topcom.connection.connected == true) { if (development.instance.currentdos.buttons[topcom.connection.id].getconnected(id)) { homecoming true; } } } } if (leftcom.connection != null) { if (d != leftcom.connection.id) { if (leftcom.connection.id == 0) { homecoming true; } else if (leftcom.connection.connected == true) { if (development.instance.currentdos.buttons[leftcom.connection.id].getconnected(id)) { homecoming true; } } } } if (rightcom.connection != null) { if (d != rightcom.connection.id) { if (rightcom.connection.id == 0) { homecoming true; } else if (rightcom.connection.connected == true) { if (development.instance.currentdos.buttons[rightcom.connection.id].getconnected(id)) { homecoming true; } } } } if (botcom.connection != null) { if (d != botcom.connection.id) { if (botcom.connection.id == 0) { homecoming true; } else if (botcom.connection.connected == true) { if (development.instance.currentdos.buttons[botcom.connection.id].getconnected(id)) { homecoming true; } } } } homecoming false; }
this happens in recursive functions don't have base of operations status ending recursion. maintain calling function until reach stack overflow.. trace code through , figure out why calls endlessly.
c# unity3d
Comments
Post a Comment