Ensure root thing is parented to remote participant
This commit is contained in:
parent
829c4cdd25
commit
dfec91cb62
@ -41,6 +41,7 @@ namespace RoboidControl.Unity {
|
||||
GameObject remoteParticipant = new GameObject("RemoteParticipant");
|
||||
Participant participant = remoteParticipant.AddComponent<Participant>();
|
||||
participant.coreParticipant = e.participant;
|
||||
participant.coreParticipant.component = participant;
|
||||
break;
|
||||
case ThingMsg.id:
|
||||
HandleThingEvent(e);
|
||||
|
@ -46,13 +46,18 @@ namespace RoboidControl.Unity {
|
||||
protected void Init(RoboidControl.Thing core) {
|
||||
this.core = core;
|
||||
this.core.component = this;
|
||||
this.owner = FindAnyObjectByType<SiteServer>();
|
||||
core.owner = this.owner.coreParticipant;
|
||||
// This is wrong, it should get the owner, which is not the siteserver
|
||||
// this.owner = FindAnyObjectByType<SiteServer>();
|
||||
// core.owner = this.owner.coreParticipant;
|
||||
this.owner = core.owner.component;
|
||||
|
||||
if (core.parent != null && core.parent.component != null) {
|
||||
this.transform.SetParent(core.parent.component.transform, false);
|
||||
this.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
else {
|
||||
this.transform.SetParent(core.owner.component.transform, false);
|
||||
}
|
||||
|
||||
if (core.position != null)
|
||||
this.transform.localPosition = core.position.ToVector3();
|
||||
@ -108,7 +113,7 @@ namespace RoboidControl.Unity {
|
||||
case ThingMsg.id:
|
||||
Debug.Log($"{this.core.id} Handle Thing");
|
||||
if (core.parent == null)
|
||||
this.transform.SetParent(null, true);
|
||||
this.transform.SetParent(core.owner.component.transform, true);
|
||||
else if (core.parent.component != null)
|
||||
this.transform.SetParent(core.parent.component.transform, true);
|
||||
break;
|
||||
|
@ -52,6 +52,14 @@ namespace RoboidControl {
|
||||
/// </summary>
|
||||
public int port = 0;
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
/// <summary>
|
||||
/// A reference to the representation of the thing in Unity
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public Unity.Participant component = null;
|
||||
#endif
|
||||
|
||||
public UdpClient udpClient = null;
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user