public void OnEnable() { localSyncObject = GetComponent <RemoteEntitySyncObject>(); localStateOverride = GetComponent <ARRHierarchicalStateOverrideComponent>(); if (localStateOverride == null) { localStateOverride = gameObject.AddComponent <ARRHierarchicalStateOverrideComponent>(); var remoteStateOverride = localSyncObject.Entity.FindComponentOfType <HierarchicalStateOverrideComponent>(); if (remoteStateOverride == null) { // if there is no HierarchicalStateOverrideComponent on the remote side yet, create one localStateOverride.Create(RemoteManagerUnity.CurrentSession); } else { // otherwise, bind our local stateOverride component to the remote component localStateOverride.Bind(remoteStateOverride); } } localStateOverride.RemoteComponent.TintColor = HighlightColor.toRemote(); localSyncObject.SyncEveryFrame = true; }
/// <summary> /// Create an address used to find a child target that is underneath a root target. If null or empty is returned, /// it is assumed that is a root target. /// </summary> protected override sealed int[] CreateAddress() { RemoteEntitySyncObject rootEntitySync = Root.GetComponentInChildren <RemoteEntitySyncObject>(); RemoteEntitySyncObject thisEntitySync = this.GetComponent <RemoteEntitySyncObject>(); return(CreateAddress(rootEntitySync, thisEntitySync)); }
private void DestroyRemoteComponent() { Object.Destroy(localCutPlaneComponent); Object.Destroy(remoteEntitySync); localCutPlaneComponent = null; remoteEntitySync = null; }
/// <summary> /// Create a new ISharingServiceTarget from a given Azure Remote Rendering Entity object that is child of the /// given SharingTargetRoot. /// </summary> public static ISharingServiceTarget CreateTarget(SharingTargetRoot root, Entity child) { if (root == null || child == null || !child.Valid) { return(null); } RemoteEntitySyncObject rootEntitySync = root.GetComponentInChildren <RemoteEntitySyncObject>(); if (rootEntitySync == null || !rootEntitySync.IsEntityValid) { return(null); } return(root.InnerTarget.AddChild(CreateAddress(rootEntitySync.Entity, child))); }
public void OnEnable() { localSyncObject = GetComponent <RemoteEntitySyncObject>(); meshComponent = GetComponent <ARRMeshComponent>(); if (meshComponent == null) { var mesh = localSyncObject.Entity.FindComponentOfType <MeshComponent>(); if (mesh != null) { gameObject.BindArrComponent <ARRMeshComponent>(mesh); meshComponent = gameObject.GetComponent <ARRMeshComponent>(); } } meshComponent.enabled = true; }
/// <summary> /// Create an address used to find a child target that is underneath a root target. If null or empty is returned, /// it is assumed that is a root target. /// </summary> private static int[] CreateAddress(RemoteEntitySyncObject root, RemoteEntitySyncObject child) { if (root == null || !root.IsEntityValid) { Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, $"Can't create sharing address for child entity '{child?.Entity?.Name}'. Can't find a valid root RemoteEntitySyncObject."); return(null); } else if (child == null || !child.IsEntityValid) { Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, $"Can't create sharing address for child entity '{child?.Entity?.Name}'. Can't find a valid RemoteEntitySyncObject for self."); return(null); } else { return(CreateAddress(root.Entity, child.Entity)); } }
private IList <ExplodeData> CaptureRemoteMeshes(RemoteEntitySyncObject syncObject) { Entity rootEntity = null; if (syncObject != null) { rootEntity = syncObject.Entity; } EntityTransform entityTransform = null; if (rootEntity != null) { entityTransform = rootEntity.CreateTransformSnapshot(); } return(ToExplodeData(entityTransform)); }
private void CreateRemoteComponent() { if (localCutPlaneComponent == null) { localCutPlaneComponent = gameObject.CreateArrComponent <ARRCutPlaneComponent>(RemoteManagerUnity.CurrentSession); } if (remoteEntitySync == null) { remoteEntitySync = gameObject.GetComponent <RemoteEntitySyncObject>(); remoteEntitySync.SyncEveryFrame = true; } localCutPlaneComponent.RemoteComponent.Normal = Axis.X; localCutPlaneComponent.RemoteComponent.FadeLength = 0.025f; localCutPlaneComponent.RemoteComponent.FadeColor = new Color4Ub(255, 128, 0, 255); localCutPlaneComponent.RemoteComponent.Enabled = true; }
/// <summary> /// Creates the specified faces. /// </summary> /// <param name="faces"> /// The faces to create. /// </param> private void CreateFaces(ClippingBoxFaces faces) { // Loop through all values foreach (ClippingBoxFaces face in Enum.GetValues(typeof(ClippingBoxFaces))) { // Is this face being passed in? if (faces.HasFlag(face)) { // Only create if not already alive if (!faceObjects.ContainsKey(face)) { // Create the object GameObject faceObject = new GameObject(Enum.GetName(typeof(ClippingBoxFaces), face)); // Parent it faceObject.transform.SetParent(transform, worldPositionStays: false); // Create the component ARRCutPlaneComponent cutPlane = faceObject.CreateArrComponent <ARRCutPlaneComponent>(RemoteManagerUnity.CurrentSession); // Configure it if (cutPlane.RemoteComponent != null) { cutPlane.RemoteComponent.Normal = FaceToNormal(face); cutPlane.RemoteComponent.FadeLength = .0000025f; cutPlane.RemoteComponent.FadeColor = new Color4Ub(0, 0, 75, 255); } RemoteEntitySyncObject syncObject = faceObject.GetComponent <RemoteEntitySyncObject>(); if (syncObject != null) { syncObject.SyncEveryFrame = true; } // Add it to the active list faceObjects[face] = faceObject; } } } }
/// <summary> /// Resolve an ISharingServiceTarget to an Azure Remote Rendering Entity object. This will search the 'root' for the remote Entity. /// </summary> private static Entity FindEntity(SharingTargetRoot root, ISharingServiceTarget target) { RemoteEntitySyncObject rootEntitySync = root?.GetComponentInChildren <RemoteEntitySyncObject>(); if (rootEntitySync == null || !rootEntitySync.IsEntityValid) { Debug.LogError($"Can't find sharing target off of '{root?.name ?? "NULL"}'. Can't find a valid root RemoteEntitySyncObject."); return(null); } Entity parentEntity = rootEntitySync.Entity; Entity resultEntity = parentEntity; int[] childIndices = target.Address; int childIndicesCount = childIndices?.Length ?? 0; for (int i = 0; i < childIndicesCount; i++) { if (parentEntity == null) { Debug.LogError($"Can't find sharing target off of '{root.name}'. The hierarchy was too shallow."); resultEntity = null; break; } int index = childIndices[i]; if (parentEntity.Children.Count <= index) { Debug.LogError($"Can't find sharing target off of '{root.name}'. The a parent didn't have enough children. Was excepted a child at index '{index}'"); resultEntity = null; break; } resultEntity = parentEntity.Children[index]; parentEntity = resultEntity; } return(resultEntity); }
void Update() { if (!RemoteManagerUnity.IsConnected) { // can't do anything while we are not connected return; } if (localCutPlaneComponent == null) { localCutPlaneComponent = gameObject.CreateArrComponent <ARRCutPlaneComponent>(RemoteManagerUnity.CurrentSession); } if (remoteEntitySync == null) { remoteEntitySync = gameObject.GetComponent <RemoteEntitySyncObject>(); remoteEntitySync.SyncEveryFrame = true; } localCutPlaneComponent.RemoteComponent.Normal = Axis.X; localCutPlaneComponent.RemoteComponent.FadeLength = 0.025f; localCutPlaneComponent.RemoteComponent.FadeColor = new Color4Ub(255, 128, 0, 255); localCutPlaneComponent.RemoteComponent.Enabled = true; }
public RemoteObjectLoadedEventData(RemoteEntitySyncObject syncObject) { SyncObject = syncObject; }
public RemoteObjectLoadedEventData(RemoteEntitySyncObject syncObject, List <EntitySnapshot> snapshot) { SyncObject = syncObject; Snapshot = snapshot; }