void Start()
        {
            m_animator = gameObject.GetComponent <Animator>();

            if (!m_animator)
            {
                m_animator = gameObject.AddComponent <Animator>();
            }

            if (AnimationAsset.AssetBundle != null)
            {
                UnityAssetLoader.LoadAsset <RuntimeAnimatorController>(AnimationAsset, (ctl) =>
                {
                    m_ctl = ctl;

                    m_animator.runtimeAnimatorController = m_ctl;
                });
            }
            else
            {
                m_ctl = Resources.Load <RuntimeAnimatorController>(AnimationAsset.AssetName);

                m_animator.runtimeAnimatorController = m_ctl;
            }
        }
        internal AnnotationGameObject Create3DAssetAnnotation(_3D.Models.AssetInstance assetInstance)
        {
            var parent        = new GameObject("3D Marker");
            var annotationObj = parent.AddComponent <AnnotationGameObject>();

            UnityAssetLoader.LoadAsset(assetInstance, parent);

            return(annotationObj);
        }
    public override AnnotationGameObject GetObjectForAnnotation(MapAnnotation <LocationMarker> annotation)
    {
        if (annotation.Marker != null)
        {
            return(CreateMarkerAnnotation(annotation.Marker));
        }
        else if (annotation.AssetInstance != null)
        {
            var parent        = new GameObject("3D Marker");
            var annotationObj = parent.AddComponent <AnnotationGameObject>();

            UnityAssetLoader.LoadAsset(annotation.AssetInstance, parent);

            return(annotationObj);
        }

        return(base.GetObjectForAnnotation(annotation));
    }
Exemple #4
0
        void Add3dAsset(MarkerAsset markerAsset)
        {
            if (markerAsset.Marker.Database != null)
            {
                LoadDataSet(markerAsset.Marker.Database);
            }

            var objs = m_trackingVuMarkers[markerAsset.Marker.Identifier];

            m_activeResourceAssets.Add(markerAsset.Marker.Identifier, markerAsset);

            if (objs != null && objs.Count() > 0)
            {
                foreach (var obj in objs)
                {
                    obj.ExtendedTracking = markerAsset.Marker.UseExtendedTracking;

                    AttachAssetObject(
                        markerAsset,
                        //markerAsset.Marker.Identifier,
                        obj.gameObject

                        /*,
                         * markerAsset.ObjectId,
                         * markerAsset.AssetInstance,
                         * markerAsset.MediaUrl,
                         * markerAsset.MediaLayout,
                         * markerAsset.OnOpen,
                         * markerAsset.OnSelect*/);
                }
            }
            else
            {
                // Preload the asset even if there's no marker yet
                UnityAssetLoader.LoadAsset <GameObject>((UnityAsset)markerAsset.AssetInstance.Asset, (obj) => { });
            }
        }
Exemple #5
0
        void AttachAssetObject(MarkerAsset asset, GameObject parent)
        {
            var activeObject = GetOrCreateActiveObject(asset.ObjectId);

            VisualMarkerWorldObject worldObj = null;

            activeObject.MarkerObjects.TryGetValue(asset.Marker.Identifier, out worldObj);

            if (worldObj != null)
            {
                worldObj.GameObject.transform.SetParent(parent.transform, false);
                worldObj.GameObject.transform.localPosition = Vector3.zero;
                worldObj.GameObject.transform.localScale    = ItemScale;
                worldObj.GameObject.transform.localRotation = Quaternion.identity;

                if (asset.OnOpen != null)
                {
                    asset.OnOpen();
                }

                worldObj.GameObject.SetActive(true);
            }
            else
            {
                if (activeObject.PendingLoads.Contains(asset.Marker.Identifier))
                {
                    return;
                }

                activeObject.PendingLoads.Add(asset.Marker.Identifier);

                UnityAssetLoader.LoadAsset <GameObject>(asset.AssetInstance.Asset as UnityAsset, (prefab) =>
                {
                    activeObject.PendingLoads.Remove(asset.Marker.Identifier);

                    // parent object could have been destroyed
                    if (prefab && parent)
                    {
                        var gameObj = Instantiate(prefab);

                        var markerObj = Instantiate(MarkerAssetObject);

                        worldObj = CreateWorldObject(markerObj, gameObj, asset.ActivationContext);

                        worldObj.Clicked += (sender, args) =>
                        {
                            if (asset.OnSelect != null)
                            {
                                asset.OnSelect();
                            }
                        };

                        gameObj.transform.SetParent(markerObj.LayoutObject.transform, false);
                        gameObj.transform.localPosition = Vector3.zero;

                        markerObj.transform.SetParent(parent.transform, false);
                        markerObj.transform.localPosition = Vector3.zero;
                        markerObj.transform.localScale    = ItemScale;
                        markerObj.transform.localRotation = Quaternion.identity;

                        if (asset.AssetInstance.Layout != null)
                        {
                            LayoutHelper.Apply(markerObj.LayoutObject.transform, asset.AssetInstance.Layout);
                        }

                        var collider = gameObj.GetComponent <Collider>();

                        if (!collider)
                        {
                            gameObj.AddComponent <SphereCollider>();
                        }

                        activeObject.MarkerObjects.Add(asset.Marker.Identifier, worldObj);

                        if (asset.OnOpen != null)
                        {
                            asset.OnOpen();
                        }
                    }
                    else
                    {
                        if (asset.MediaUrl != null)
                        {
                            AttachMediaObject(asset, parent);
                        }
                    }
                });
            }
        }