Skip to content

Commit f31b6af

Browse files
committed
to Component 拡張
1 parent 8a1ae92 commit f31b6af

File tree

3 files changed

+100
-9
lines changed

3 files changed

+100
-9
lines changed

Packages/com.mimylab.fukuroudon/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
- ActiveRelay to Physbone
1414
- ActiveRelay by Physbone
1515
- ActiveRelay by Contact
16+
- ActiveRelay to Component で切り替えられるコンポーネントに以下を追加しました。
17+
- UdonBehaviour
18+
- U# コンポーネント(UdonSharpBehaviour を継承したもの)
19+
- VRC Constraint
20+
- VRC Physbone
21+
- VRC Contact Sender
22+
- VRC Contact Receiver
1623

1724
## [3.12.0] - 2025/10/26
1825

Packages/com.mimylab.fukuroudon/Runtime/ActiveRelay/Scripts/ActiveRelayToComponent.asset

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ MonoBehaviour:
4343
Data:
4444
- Name:
4545
Entry: 12
46-
Data: 3
46+
Data: 4
4747
- Name:
4848
Entry: 7
4949
Data:
@@ -230,6 +230,72 @@ MonoBehaviour:
230230
- Name:
231231
Entry: 8
232232
Data:
233+
- Name:
234+
Entry: 7
235+
Data:
236+
- Name: $k
237+
Entry: 1
238+
Data: _udonSharpBehaviours
239+
- Name: $v
240+
Entry: 7
241+
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
242+
- Name: <Name>k__BackingField
243+
Entry: 1
244+
Data: _udonSharpBehaviours
245+
- Name: <UserType>k__BackingField
246+
Entry: 7
247+
Data: 16|System.RuntimeType, mscorlib
248+
- Name:
249+
Entry: 1
250+
Data: UdonSharp.UdonSharpBehaviour[], UdonSharp.Runtime
251+
- Name:
252+
Entry: 8
253+
Data:
254+
- Name: <SystemType>k__BackingField
255+
Entry: 9
256+
Data: 8
257+
- Name: <SyncMode>k__BackingField
258+
Entry: 7
259+
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
260+
- Name:
261+
Entry: 6
262+
Data:
263+
- Name:
264+
Entry: 8
265+
Data:
266+
- Name: <IsSerialized>k__BackingField
267+
Entry: 5
268+
Data: true
269+
- Name: _fieldAttributes
270+
Entry: 7
271+
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
272+
- Name:
273+
Entry: 12
274+
Data: 2
275+
- Name:
276+
Entry: 7
277+
Data: 18|UnityEngine.SerializeField, UnityEngine.CoreModule
278+
- Name:
279+
Entry: 8
280+
Data:
281+
- Name:
282+
Entry: 7
283+
Data: 19|UnityEngine.HideInInspector, UnityEngine.CoreModule
284+
- Name:
285+
Entry: 8
286+
Data:
287+
- Name:
288+
Entry: 13
289+
Data:
290+
- Name:
291+
Entry: 8
292+
Data:
293+
- Name:
294+
Entry: 8
295+
Data:
296+
- Name:
297+
Entry: 8
298+
Data:
233299
- Name:
234300
Entry: 13
235301
Data:

Packages/com.mimylab.fukuroudon/Runtime/ActiveRelay/Scripts/ActiveRelayToComponent.cs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ namespace MimyLab.FukuroUdon
99
using UdonSharp;
1010
using UnityEngine;
1111
using UnityEngine.Animations;
12-
using VRC.Dynamics;
1312
using VRC.SDK3.Dynamics.Constraint.Components;
14-
using VRC.SDK3.Dynamics.Contact.Components;
1513
using VRC.SDK3.Dynamics.PhysBone.Components;
14+
using VRC.SDK3.Dynamics.Contact.Components;
1615
using VRC.Udon;
1716

1817
[HelpURL("https://github.com/mimyquality/FukuroUdon/wiki/Active-Relay#activerelay-to-component")]
@@ -28,26 +27,40 @@ public class ActiveRelayToComponent : UdonSharpBehaviour
2827
[SerializeField]
2928
private bool _invert = false;
3029

30+
[SerializeField, HideInInspector]
31+
private UdonSharpBehaviour[] _udonSharpBehaviours = new UdonSharpBehaviour[0];
32+
3133
#if !COMPILER_UDONSHARP && UNITY_EDITOR
3234
private void OnValidate()
3335
{
34-
var count = 0;
35-
var tmp = new Component[_components.Length];
36+
var tmp_Components = new Component[_components.Length];
37+
var componentCount = 0;
38+
// U# はプロキシー概念があるので別途 UdonSharpBehaviour 配列を用意して管理する
39+
var tmp_udonSharpBehaviours = new UdonSharpBehaviour[_components.Length];
40+
var usbCount = 0;
3641
foreach (var component in _components)
3742
{
3843
if (ValidateComponentType(component))
3944
{
40-
tmp[count++] = component;
45+
tmp_Components[componentCount++] = component;
46+
47+
if (component is UdonSharpBehaviour usb)
48+
{
49+
tmp_udonSharpBehaviours[usbCount++] = usb;
50+
}
4151
}
4252
}
43-
System.Array.Resize(ref tmp, count);
44-
_components = tmp;
53+
System.Array.Resize(ref tmp_Components, componentCount);
54+
_components = tmp_Components;
55+
System.Array.Resize(ref tmp_udonSharpBehaviours, usbCount);
56+
_udonSharpBehaviours = tmp_udonSharpBehaviours;
4557
}
4658

4759
private bool ValidateComponentType(Component component)
4860
{
4961
if (!component) { return false; }
5062

63+
var type = component.GetType();
5164
if (component is Collider) { return true; }
5265
if (component is Renderer) { return true; }
5366
// 個別に羅列の必要ある
@@ -72,7 +85,7 @@ private bool ValidateComponentType(Component component)
7285
if (component is Camera) { return true; }
7386
if (component is Animator) { return true; }
7487
if (component is UdonBehaviour) { return true; }
75-
//if (component is UdonSharpBehaviour) { return true; } // なんとかする
88+
if (component is UdonSharpBehaviour) { return true; }
7689
if (component is VRCParentConstraint) { return true; }
7790
if (component is VRCPositionConstraint) { return true; }
7891
if (component is VRCRotationConstraint) { return true; }
@@ -156,6 +169,11 @@ private void ToggleComponents(bool value)
156169
// else if (type == typeof(AudioListener)) { var downCasted = (AudioListener)component; downCasted.enabled = value; }
157170
// else if (type == typeof(Cloth)) { var downCasted = (Cloth)component; downCasted.enabled = value; }
158171
}
172+
foreach (var udonSharpBehaviour in _udonSharpBehaviours)
173+
{
174+
if (!udonSharpBehaviour) continue;
175+
udonSharpBehaviour.enabled = value;
176+
}
159177
}
160178
}
161179
}

0 commit comments

Comments
 (0)