Skip to content

Commit 36c601f

Browse files
Support the last MonoBehaviour message: OnAudioFilterRead
1 parent ea643d0 commit 36c601f

5 files changed

Lines changed: 41 additions & 32 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ The code generator supports:
179179
* Methods (including generic parameters and return types)
180180
* Fields (including generic types)
181181
* Properties (getters and setters) (including generic types)
182-
* `MonoBehaviour` classes with "message" functions like `Update` (except `OnAudioFilterRead`)
182+
* `MonoBehaviour` classes with "message" functions like `Update`
183183
* `out` and `ref` parameters
184184
* Enumerations
185185
* Exceptions

Unity/Assets/NativeScript/Bindings.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ static int SystemInt32Array1GetItem1(int thisHandle, int index0)
22672267
{
22682268
try
22692269
{
2270-
var thiz = (System.Int32[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2270+
var thiz = (int[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
22712271
var returnValue = thiz[index0];
22722272
return returnValue;
22732273
}
@@ -2290,7 +2290,7 @@ static void SystemInt32Array1SetItem1(int thisHandle, int index0, int item)
22902290
{
22912291
try
22922292
{
2293-
var thiz = (System.Int32[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2293+
var thiz = (int[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
22942294
thiz[index0] = item;
22952295
}
22962296
catch (System.NullReferenceException ex)
@@ -2332,7 +2332,7 @@ static float SystemSingleArray1GetItem1(int thisHandle, int index0)
23322332
{
23332333
try
23342334
{
2335-
var thiz = (System.Single[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2335+
var thiz = (float[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
23362336
var returnValue = thiz[index0];
23372337
return returnValue;
23382338
}
@@ -2355,7 +2355,7 @@ static void SystemSingleArray1SetItem1(int thisHandle, int index0, float item)
23552355
{
23562356
try
23572357
{
2358-
var thiz = (System.Single[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2358+
var thiz = (float[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
23592359
thiz[index0] = item;
23602360
}
23612361
catch (System.NullReferenceException ex)
@@ -2397,7 +2397,7 @@ static int SystemSingleArray2GetLength2(int thisHandle, int dimension)
23972397
{
23982398
try
23992399
{
2400-
var thiz = (System.Single[,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2400+
var thiz = (float[,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
24012401
var returnValue = thiz.GetLength(dimension);
24022402
return returnValue;
24032403
}
@@ -2420,7 +2420,7 @@ static float SystemSingleArray2GetItem2(int thisHandle, int index0, int index1)
24202420
{
24212421
try
24222422
{
2423-
var thiz = (System.Single[,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2423+
var thiz = (float[,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
24242424
var returnValue = thiz[index0, index1];
24252425
return returnValue;
24262426
}
@@ -2443,7 +2443,7 @@ static void SystemSingleArray2SetItem2(int thisHandle, int index0, int index1, f
24432443
{
24442444
try
24452445
{
2446-
var thiz = (System.Single[,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2446+
var thiz = (float[,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
24472447
thiz[index0, index1] = item;
24482448
}
24492449
catch (System.NullReferenceException ex)
@@ -2485,7 +2485,7 @@ static int SystemSingleArray3GetLength3(int thisHandle, int dimension)
24852485
{
24862486
try
24872487
{
2488-
var thiz = (System.Single[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2488+
var thiz = (float[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
24892489
var returnValue = thiz.GetLength(dimension);
24902490
return returnValue;
24912491
}
@@ -2508,7 +2508,7 @@ static float SystemSingleArray3GetItem3(int thisHandle, int index0, int index1,
25082508
{
25092509
try
25102510
{
2511-
var thiz = (System.Single[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2511+
var thiz = (float[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
25122512
var returnValue = thiz[index0, index1, index2];
25132513
return returnValue;
25142514
}
@@ -2531,7 +2531,7 @@ static void SystemSingleArray3SetItem3(int thisHandle, int index0, int index1, i
25312531
{
25322532
try
25332533
{
2534-
var thiz = (System.Single[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2534+
var thiz = (float[,,])NativeScript.Bindings.ObjectStore.Get(thisHandle);
25352535
thiz[index0, index1, index2] = item;
25362536
}
25372537
catch (System.NullReferenceException ex)
@@ -2573,7 +2573,7 @@ static int SystemStringArray1GetItem1(int thisHandle, int index0)
25732573
{
25742574
try
25752575
{
2576-
var thiz = (System.String[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2576+
var thiz = (string[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
25772577
var returnValue = thiz[index0];
25782578
return NativeScript.Bindings.ObjectStore.GetHandle(returnValue);
25792579
}
@@ -2596,7 +2596,7 @@ static void SystemStringArray1SetItem1(int thisHandle, int index0, int itemHandl
25962596
{
25972597
try
25982598
{
2599-
var thiz = (System.String[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
2599+
var thiz = (string[])NativeScript.Bindings.ObjectStore.Get(thisHandle);
26002600
var item = (string)NativeScript.Bindings.ObjectStore.Get(itemHandle);
26012601
thiz[index0] = item;
26022602
}

Unity/Assets/NativeScript/Editor/GenerateBindings.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ public MessageInfo(
235235
new MessageInfo("OnApplicationFocus", typeof(bool)),
236236
new MessageInfo("OnApplicationPause", typeof(bool)),
237237
new MessageInfo("OnApplicationQuit"),
238-
// TODO re-enable when arrays are supported
239-
// new MessageInfo("OnAudioFilterRead", typeof(float[]), typeof(int)),
238+
new MessageInfo("OnAudioFilterRead", typeof(float[]), typeof(int)),
240239
new MessageInfo("OnBecameInvisible"),
241240
new MessageInfo("OnBecameVisible"),
242241
new MessageInfo("OnCollisionEnter", typeof(Collision)),
@@ -6718,6 +6717,15 @@ static void AppendCsharpTypeName(
67186717
{
67196718
output.Append("string");
67206719
}
6720+
else if (type.IsArray)
6721+
{
6722+
AppendCsharpTypeName(
6723+
type.GetElementType(),
6724+
output);
6725+
output.Append('[');
6726+
output.Append(',', type.GetArrayRank()-1);
6727+
output.Append(']');
6728+
}
67216729
else
67226730
{
67236731
output.Append(type.Namespace);
@@ -6794,14 +6802,15 @@ static void AppendCppTypeName(
67946802
}
67956803
else if (type.IsArray)
67966804
{
6805+
int rank = type.GetArrayRank();
67976806
output.Append("System::Array");
6798-
output.Append(type.GetArrayRank());
6807+
output.Append(rank);
67996808
output.Append('<');
6800-
int rank = type.GetArrayRank();
6809+
Type elementType = type.GetElementType();
68016810
for (int i = 0; i < rank; ++i)
68026811
{
6803-
AppendTypeNameWithoutSuffixes(
6804-
type.Name,
6812+
AppendCppTypeName(
6813+
elementType,
68056814
output);
68066815
if (i != rank -1)
68076816
{

Unity/CppSource/NativeScript/Bindings.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3116,7 +3116,7 @@ namespace UnityEngine
31163116
return Handle != other.Handle;
31173117
}
31183118

3119-
System::Array1<Resolution> Screen::GetResolutions()
3119+
System::Array1<UnityEngine::Resolution> Screen::GetResolutions()
31203120
{
31213121
auto returnValue = Plugin::UnityEngineScreenPropertyGetResolutions();
31223122
if (Plugin::unhandledCsharpException)
@@ -3126,7 +3126,7 @@ namespace UnityEngine
31263126
ex->ThrowReferenceToThis();
31273127
delete ex;
31283128
}
3129-
return System::Array1<Resolution>(Plugin::InternalUse::Only, returnValue);
3129+
return System::Array1<UnityEngine::Resolution>(Plugin::InternalUse::Only, returnValue);
31303130
}
31313131
}
31323132

@@ -3238,7 +3238,7 @@ namespace UnityEngine
32383238
return Handle != other.Handle;
32393239
}
32403240

3241-
int32_t Physics::RaycastNonAlloc(UnityEngine::Ray& ray, System::Array1<RaycastHit> results)
3241+
int32_t Physics::RaycastNonAlloc(UnityEngine::Ray& ray, System::Array1<UnityEngine::RaycastHit> results)
32423242
{
32433243
auto returnValue = Plugin::UnityEnginePhysicsMethodRaycastNonAllocUnityEngineRay_UnityEngineRaycastHit(ray, results.Handle);
32443244
if (Plugin::unhandledCsharpException)
@@ -3251,7 +3251,7 @@ namespace UnityEngine
32513251
return returnValue;
32523252
}
32533253

3254-
System::Array1<RaycastHit> Physics::RaycastAll(UnityEngine::Ray& ray)
3254+
System::Array1<UnityEngine::RaycastHit> Physics::RaycastAll(UnityEngine::Ray& ray)
32553255
{
32563256
auto returnValue = Plugin::UnityEnginePhysicsMethodRaycastAllUnityEngineRay(ray);
32573257
if (Plugin::unhandledCsharpException)
@@ -3261,7 +3261,7 @@ namespace UnityEngine
32613261
ex->ThrowReferenceToThis();
32623262
delete ex;
32633263
}
3264-
return System::Array1<RaycastHit>(Plugin::InternalUse::Only, returnValue);
3264+
return System::Array1<UnityEngine::RaycastHit>(Plugin::InternalUse::Only, returnValue);
32653265
}
32663266
}
32673267

@@ -3385,7 +3385,7 @@ namespace UnityEngine
33853385
}
33863386
}
33873387

3388-
System::Array1<GradientColorKey> Gradient::GetColorKeys()
3388+
System::Array1<UnityEngine::GradientColorKey> Gradient::GetColorKeys()
33893389
{
33903390
auto returnValue = Plugin::UnityEngineGradientPropertyGetColorKeys(Handle);
33913391
if (Plugin::unhandledCsharpException)
@@ -3395,10 +3395,10 @@ namespace UnityEngine
33953395
ex->ThrowReferenceToThis();
33963396
delete ex;
33973397
}
3398-
return System::Array1<GradientColorKey>(Plugin::InternalUse::Only, returnValue);
3398+
return System::Array1<UnityEngine::GradientColorKey>(Plugin::InternalUse::Only, returnValue);
33993399
}
34003400

3401-
void Gradient::SetColorKeys(System::Array1<GradientColorKey> value)
3401+
void Gradient::SetColorKeys(System::Array1<UnityEngine::GradientColorKey> value)
34023402
{
34033403
Plugin::UnityEngineGradientPropertySetColorKeys(Handle, value.Handle);
34043404
if (Plugin::unhandledCsharpException)

Unity/CppSource/NativeScript/Bindings.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ namespace UnityEngine
10471047
Screen& operator=(Screen&& other);
10481048
bool operator==(const Screen& other) const;
10491049
bool operator!=(const Screen& other) const;
1050-
static System::Array1<Resolution> GetResolutions();
1050+
static System::Array1<UnityEngine::Resolution> GetResolutions();
10511051
};
10521052
}
10531053

@@ -1076,8 +1076,8 @@ namespace UnityEngine
10761076
Physics& operator=(Physics&& other);
10771077
bool operator==(const Physics& other) const;
10781078
bool operator!=(const Physics& other) const;
1079-
static int32_t RaycastNonAlloc(UnityEngine::Ray& ray, System::Array1<RaycastHit> results);
1080-
static System::Array1<RaycastHit> RaycastAll(UnityEngine::Ray& ray);
1079+
static int32_t RaycastNonAlloc(UnityEngine::Ray& ray, System::Array1<UnityEngine::RaycastHit> results);
1080+
static System::Array1<UnityEngine::RaycastHit> RaycastAll(UnityEngine::Ray& ray);
10811081
};
10821082
}
10831083

@@ -1118,8 +1118,8 @@ namespace UnityEngine
11181118
bool operator==(const Gradient& other) const;
11191119
bool operator!=(const Gradient& other) const;
11201120
Gradient();
1121-
System::Array1<GradientColorKey> GetColorKeys();
1122-
void SetColorKeys(System::Array1<GradientColorKey> value);
1121+
System::Array1<UnityEngine::GradientColorKey> GetColorKeys();
1122+
void SetColorKeys(System::Array1<UnityEngine::GradientColorKey> value);
11231123
};
11241124
}
11251125

0 commit comments

Comments
 (0)