jacksondunstan/UnityNativeScripting

Property bug?

sonygod opened this issue · 3 comments

Property bug?

{
			"Name": "UnityEngine.GameObject",
			"Constructors": [
			],
			"Methods": [
				{
					"Name": "AddComponent",
					"ParamTypes": [],
					"GenericParams": [
						{
							"Types": [
								"MyGame.BaseBallScript"
							]
						}
					]
				},
				{
					"Name": "CreatePrimitive",
					"ParamTypes": [
						"UnityEngine.PrimitiveType"
					]
				}
			],
			"Properties":[
				{
				   "Name":"tag",
				   "Set":{},
				   "Get":{}
				}
			]
			
		},

add property tag to gameobject ,build and run ,throw error

NullReferenceException: Object reference not set to an instance of an object
NativeScript.Bindings.UnityEngineMonoBehaviourPropertyGetTransform (Int32 thisHandle) (at Assets/NativeScript/Bindings.cs:1403)

how to fixed?

@jacksondunstan my unity version between 5.6 and 20.18.1 and vs2017 win64

it's seem no matter about the properties name ,but When I change json ,it's alway run error.

it's seem you cod is not automatic create warp from Json?

you have to write some bingding code in binding.cs?

like here ?

/*BEGIN DELEGATE TYPES*/ delegate void ReleaseSystemDecimalDelegateType(int handle); delegate int SystemDecimalConstructorSystemDoubleDelegateType(double value); delegate int SystemDecimalConstructorSystemUInt64DelegateType(ulong value); delegate int BoxDecimalDelegateType(int valHandle); delegate int UnboxDecimalDelegateType(int valHandle); delegate UnityEngine.Vector3 UnityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingleDelegateType(float x, float y, float z); delegate UnityEngine.Vector3 UnityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3DelegateType(ref UnityEngine.Vector3 a, ref UnityEngine.Vector3 b); delegate int BoxVector3DelegateType(ref UnityEngine.Vector3 val); delegate UnityEngine.Vector3 UnboxVector3DelegateType(int valHandle); delegate int UnityEngineObjectPropertyGetNameDelegateType(int thisHandle); delegate void UnityEngineObjectPropertySetNameDelegateType(int thisHandle, int valueHandle); delegate int UnityEngineComponentPropertyGetTransformDelegateType(int thisHandle); delegate UnityEngine.Vector3 UnityEngineTransformPropertyGetPositionDelegateType(int thisHandle); delegate void UnityEngineTransformPropertySetPositionDelegateType(int thisHandle, ref UnityEngine.Vector3 value); delegate int SystemCollectionsIEnumeratorPropertyGetCurrentDelegateType(int thisHandle); delegate bool SystemCollectionsIEnumeratorMethodMoveNextDelegateType(int thisHandle); delegate int UnityEngineGameObjectMethodAddComponentMyGameBaseBallScriptDelegateType(int thisHandle); delegate int UnityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveTypeDelegateType(UnityEngine.PrimitiveType type); delegate void UnityEngineDebugMethodLogSystemObjectDelegateType(int messageHandle); delegate int UnityEngineMonoBehaviourPropertyGetTransformDelegateType(int thisHandle); delegate int SystemExceptionConstructorSystemStringDelegateType(int messageHandle); delegate int BoxPrimitiveTypeDelegateType(UnityEngine.PrimitiveType val); delegate UnityEngine.PrimitiveType UnboxPrimitiveTypeDelegateType(int valHandle); delegate float UnityEngineTimePropertyGetDeltaTimeDelegateType(); delegate void BaseBallScriptConstructorDelegateType(int cppHandle, ref int handle); delegate void ReleaseBaseBallScriptDelegateType(int handle); delegate int BoxBooleanDelegateType(bool val); delegate bool UnboxBooleanDelegateType(int valHandle); delegate int BoxSByteDelegateType(sbyte val); delegate sbyte UnboxSByteDelegateType(int valHandle); delegate int BoxByteDelegateType(byte val); delegate byte UnboxByteDelegateType(int valHandle); delegate int BoxInt16DelegateType(short val); delegate short UnboxInt16DelegateType(int valHandle); delegate int BoxUInt16DelegateType(ushort val); delegate ushort UnboxUInt16DelegateType(int valHandle); delegate int BoxInt32DelegateType(int val); delegate int UnboxInt32DelegateType(int valHandle); delegate int BoxUInt32DelegateType(uint val); delegate uint UnboxUInt32DelegateType(int valHandle); delegate int BoxInt64DelegateType(long val); delegate long UnboxInt64DelegateType(int valHandle); delegate int BoxUInt64DelegateType(ulong val); delegate ulong UnboxUInt64DelegateType(int valHandle); delegate int BoxCharDelegateType(char val); delegate char UnboxCharDelegateType(int valHandle); delegate int BoxSingleDelegateType(float val); delegate float UnboxSingleDelegateType(int valHandle); delegate int BoxDoubleDelegateType(double val); delegate double UnboxDoubleDelegateType(int valHandle); /*END DELEGATE TYPES*/

I found there is an bug in GenerateBindings.cs ,

you forget return result finally ,and allso you can't find index like \n /t/t in windows system.

` static string InjectIntoString(
string contents,
string beginMarker,
string endMarker,
string text)
{

        var len = contents.Length;
        for (int startIndex = 0; ;)
        {
            int beginIndex = contents.IndexOf(beginMarker, startIndex);
            if (beginIndex < 0)
            {
                Debug.LogError("can't find "+ beginMarker);
                return contents;
            }
            int afterBeginIndex = beginIndex + beginMarker.Length;
            int endIndex = contents.IndexOf(endMarker, afterBeginIndex);
            if (endIndex < 0)
            {
                throw new Exception(
                    string.Format(
                        "No end ({0}) for begin ({1}) at {2} after {3}",
                        endMarker,
                        beginMarker,
                        beginIndex,
                        startIndex));
            }
            string begin = contents.Substring(0, afterBeginIndex);
            string end = contents.Substring(endIndex);
            contents = begin + text + end;
            startIndex = beginIndex + 1;
            Debug.LogWarning("ok,return"+beginMarker+ (contents.Length==len));
            return contents;
        }
    }`