Exemple #1
0
        public override void OnItemsAdded(object sender, AddedEventArgs <SlamTrackedObject> e)
        {
            if (!IsSenderVisible(sender))
            {
                return;
            }
            lock (GameObjects)
            {
                foreach (var obj in e.AddedItems)
                {
                    Pose pose = GetObjectPose(obj);
                    MainThreadInvoker.Enqueue(() =>
                    {
                        var go = ObservationsPool.Spawn(pose.position, pose.rotation);
                        GameObjects[(sender.GetHashCode(), obj.Id)] = go;

                        var dc = go.GetComponent(DataComponent <SlamTrackedObject> .GetInstantiable());
                        if (dc == null)
                        {
                            dc = go.AddComponent(DataComponent <SlamTrackedObject> .GetInstantiable());
                        }
                        var dataComponent       = (DataComponent <SlamTrackedObject>)dc;
                        dataComponent.Data      = obj;
                        dataComponent.Container = sender as IContainer <SlamTrackedObject>;

                        go.transform.Find("Label").GetComponent <TMP_Text>().text =
                            $"{(sender as TrackedObjectsContainer)?.ObjectLabel} #{obj.Id}";
                    });
        public override void ShowItems(object sender, IEnumerable <TCloudItem> items)
        {
            if (!IsSenderVisible(sender))
            {
                return;
            }
            OnClear(sender);
            lock (GameObjects)
            {
                foreach (var obj in items)
                {
                    Pose pose = GetObjectPose(obj);
                    MainThreadInvoker.Enqueue(() =>
                    {
                        var go = ObservationsPool.Spawn(pose.position * _scale, pose.rotation);
                        GameObjects[(sender.GetHashCode(), obj.Id)] = go;
                        go.GetComponent <MeshRenderer>().material.SetColor(EmissionColor, obj.AsPoint().Color);

                        var dc = go.GetComponent(DataComponent <TCloudItem> .GetInstantiable());
                        if (dc == null)
                        {
                            dc = go.AddComponent(DataComponent <TCloudItem> .GetInstantiable());
                        }
                        var dataComponent  = (DataComponent <TCloudItem>)dc;
                        dataComponent.Data = obj;
                    });