Jump to content

Code Reflection in Unigine


photo

Recommended Posts

Posted

Hi Guys,

 

i have a question for Reflection in Unigine. How is it possible to read out the name of a calling function.

 

Here the Code in Java which i could really need in Unigine:

StackTraceElement[] trace = new Throwable().getStackTrace();
	int count = 0;
	int i = 0;
	int idxFunctionName = 2;
	int idxCallFktInfo = 3;
	String refFunctionName = "";

	count = trace.length;

	for (i=1; i == (count -1); i++)
	{
		if (trace[i].getMethodName().toLowerCase() != "LogToFile".toLowerCase())
		{
			idxFunctionName = i;
               idxCallFktInfo = idxFunctionName + 1;
               break;
		}
	}

	if (count > idxCallFktInfo)
	{
		String temp = trace[idxFunctionName].getClassName().toString() + ":" + trace[idxFunctionName].getMethodName().toString();
		refFunctionName = temp;
	}
	else if (count > idxFunctionName)
	{
		String temp = trace[idxFunctionName].getClassName().toString() + ":" + trace[idxFunctionName].getMethodName().toString();
		refFunctionName = temp;
	}

	return refFunctionName;

 

Can someone tell me, how I can make the same in Ungine?

Posted

Reflection is not possible. Unigine scripts have C++ like syntax, so neither Java nor C# functionality is relevant.

Posted

I know that Unigine has C++ Syntax. I wrote the java.code as an example. I thoughed it was clear. But at least i know now

that reflection is not possible, thx.

×
×
  • Create New...