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)); }
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) => { }); } }
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); } } }); } }
protected virtual void Initialize() { Platform.Instance.Initialize(); if (AppConfig) { WebServices.Instance.AppId = AppConfig.AppId; WebServices.Instance.ApiKey = AppConfig.ApiKey; WebServices.Instance.SetConfig(AppConfig.ConfigName); } WebServices.Instance.Initialize(); DebugPlayerLocation.Instance.Initialize(); ScriptExtensions.Initialize( Platform.Instance.LocationManager, Platform.Instance.BeaconManager, ForegroundPositionService.Instance.Compass); ARScriptExtensions.Initialize(); ForegroundPositionService.Instance.Initialize(); ScriptRunnerManager.Instance.AllowMultiple = AllowMultipleScriptRunners; WebServices.Instance.AddAssetDirectory(CharacterDirectory.Instance); WebServices.Instance.AddAssetDirectory(CollectibleDirectory.Instance); WebServices.Instance.AddAssetDirectory(ScriptRunnerDirectory.Instance); WebServices.Instance.AddAssetDirectory(RecipeDirectory.Instance); if (PreLoadAssetBundles) { WebServices.Instance.AddAssetDirectory(new AssetDirectory <Motive.Unity.Models.AssetBundle>()); } AppManager.Instance.OnLoadComplete(() => { var scripts = ScriptObjectDirectory.Instance.GetAllObjects <Script>(); ScriptManager.Instance.SetScripts(scripts); if (PreLoadAssetBundles) { UnityAssetLoader.PreloadBundles(ScriptObjectDirectory.Instance.GetAllObjects <Motive.Unity.Models.AssetBundle>()); } //Unzipping all GLTF files //BinaryAssetLoader.PreloadBundles(ScriptObjectDirectory.Instance.GetAllObjects<Motive._3D.Models.BinaryAsset>()); var locationCatalogs = ScriptObjectDirectory.Instance.GetAllCatalogs <Location>(); if (locationCatalogs != null) { LocationCache.Instance.AddLocationsToCache(locationCatalogs.SelectMany(c => c)); } }); bool readyForLaunch = true; Action launchScripts = () => { if (readyForLaunch) { ScriptRunnerManager.Instance.LaunchRunningScripts(ScriptRunnerDirectory.Instance); } }; #if MOTIVE_IAP readyForLaunch = false; if (AutoLaunchScriptRunners) { EpisodePurchaseManager.Instance.InitializeComplete += (caller, args) => { readyForLaunch = true; launchScripts(); }; } EpisodePurchaseManager.Instance.Initialize(); #endif if (AutoLaunchScriptRunners) { ScriptManager.Instance.ScriptsUpdated += (caller, args) => { launchScripts(); }; } AppManager.Instance.Initialize(); Platform.Instance.StartSensors(); TodoManager.Instance.Initialize(); }