public virtual bool InstantiateLibraryObject(LibraryObject libObj) { Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); if (raycastMode == RaycastMode.MOUSE_POSITION) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); } else if (raycastMode == RaycastMode.CAMERA_CENTER) { #if UNITY_EDITOR ray.direction = new Vector3(0f, -1f, 1f); // EDITOR hardcoded front down ray #endif } int layerMask = 1 << LayerMask.NameToLayer("ARGameObject"); // Planes are in layer ARGameObject RaycastHit rayHit; if (Physics.Raycast(ray, out rayHit, float.MaxValue, layerMask)) { GameObject go = InstantiateLibraryObject(libObj, rayHit.point); return(go != null); } Debug.Log("NO HIT"); return(false); }
public override bool InstantiateLibraryObject(LibraryObject libObj) { //return base.InstantiateLibraryObject(libObj); // DONT raycast planes, but place it by GPS difference if (!hasDetectedPlane || !hasGPSData || !hasCompassData) { return(false); } GeolocatedObject geoObj = libObj as GeolocatedObject; if (geoObj == null) { Debug.Log("object is not Geolocated"); return(false); } LocationTools.LocationData to = new LocationTools.LocationData(); to.latitude = geoObj.latitude; to.longitude = geoObj.longitude; Vector3 offset = LocationTools.GetMetersDistanceHeadingNorth(gpsData, to); Vector3 camPosOnFloor = detectedPlane.plane.ClosestPointOnPlane(Camera.main.transform.position); //Vector3 worldPos = camOnPlane + Quaternion.identity * offset; // assuming north is forward for now // ORIENT North to apply offset Vector3 headingVector = Camera.main.transform.up; // Cam up is heading compassHeading (top of screen vector) if (Camera.main.transform.forward.y >= 0) { // If cam is looking to the sky - then we have to use the FWD instead, since compass heading seems to be in accordance with Forward instead of Up headingVector = Camera.main.transform.forward; } //-project into the plane and get north in plane Vector3 headingOnFloor = Vector3.ProjectOnPlane(headingVector, detectedPlane.plane.normal).normalized; Vector3 northOnFloor = Quaternion.AngleAxis(-compassHeading, Vector3.up) * headingOnFloor; northOnFloor = northOnFloor.normalized; Vector3 worldPos = camPosOnFloor + Quaternion.FromToRotation(Vector3.forward, northOnFloor) * offset; Debug.Log("Instantiating Geolocated obj. GPSData: (" + gpsData.latitude + "," + gpsData.longitude + ")" + " CompassHeading: " + compassHeading + " metersDist: " + offset.ToString("F2") + " Resulting worldPos: " + worldPos.ToString("F2") ); GameObject obj = InstantiateLibraryObject(libObj, worldPos); //obj.transform.rotation = Quaternion.FromToRotation(Vector3.forward, northOnPlane);// when heading is exactly 180.0 Unity AngleAxis chooses to make a rotation in X axis instead of Y, turning things up-down obj.transform.rotation = Quaternion.LookRotation(northOnFloor, Vector3.up); // Orient North - model is done with fwd North return(true); }
public virtual void SelectLibraryObject(LibraryObject libObj) { if (!IsLibraryObject(libObj)) { return; } selectedLibraryObject = libObj; if (OnLibraryObjectSelected != null) { OnLibraryObjectSelected.Invoke(libObj); } }
public bool IsLibraryObject(LibraryObject libObj) { if (libObj == null) { return(true); } bool ret = libraryObjects.Contains(libObj); if (!ret) { Debug.Log("IsLibraryObject : " + libObj.ToString() + " : " + ret); } return(ret); }
public void Populate(ScrollLibrary scrollLib, LibraryObject libObj, ToggleGroup group = null) { this.scrollLib = scrollLib; this.libObj = libObj; label.text = libObj.displayName; if (libObj.thumbnail != null) { icon.enabled = true; icon.sprite = libObj.thumbnail; } if (group != null) { toggle.group = group; } }
public override void SelectLibraryObject(LibraryObject libObj) { if (!IsLibraryObject(libObj)) { return; } base.SelectLibraryObject(libObj); if (libObj == null) { foreach (LibraryItemUI item in uiItems) { item.Deselect(); } } }
void OnStoreItemReady(ScriptableStoreItem item, Object asset) { // event is called at startup for downloaded items, then when bought&downloaded //add asset items to Library ScriptableLibrary lib = asset as ScriptableLibrary; // item asset is a library itself, and can contain several objects foreach (ScriptableLibraryObject scriptLibObj in lib.libObjects) { Debug.Log("STORE scriptableLibraryObject: " + scriptLibObj.displayName); LibraryObject libObj = new LibraryObject(); libObj.prefab = scriptLibObj.prefab; libObj.displayName = scriptLibObj.displayName; libObj.thumbnail = scriptLibObj.thumbnail; storeObjects.Add(libObj); // each item is appended - } ResetLibraryObjects(); }
public LibraryObjectInfoViewModel(LibraryObject libraryObject) { if (libraryObject.Quantity > 0 || libraryObject.Category > 1) { Buttonstatus = "Låna"; } else { Buttonstatus = "S**t"; } _repo = new GeneralRepository(); //author = new Author(); currentBook = libraryObject; //GetAuthor(); AddLoan = new RelayCommand(_ => AddToCart(), _ => libraryObject.Category > 1 || libraryObject.Quantity > 0); GetCard(); }
public virtual bool InstantiateLibraryObject() { if (objectLibrary == null) { Debug.LogError("NO LIB"); return(false); } LibraryObject libObj = objectLibrary.SelectedLibraryObject; if (libObj == null) { Debug.Log("NO SEL OBJ"); return(false); } else { return(InstantiateLibraryObject(libObj)); } }
protected virtual void FetchLibrary(ScriptableLibrary scriptableLibrary) { if (scriptableLibrary != null) { List <LibraryObject> libObjects = new List <LibraryObject>(); //foreach (GameObject prefab in scriptableLibrary.prefabs) Debug.Log("FetchLibrary " + scriptableLibrary.libObjects.Count); foreach (ScriptableLibraryObject scriptLibObj in scriptableLibrary.libObjects) { Debug.Log("scriptableLibraryObject: " + scriptLibObj.displayName); LibraryObject libObj = new LibraryObject(); libObj.prefab = scriptLibObj.prefab; libObj.displayName = scriptLibObj.displayName; libObj.thumbnail = scriptLibObj.thumbnail; libObjects.Add(libObj); } objectLibrary.SetLibraryObjects(libObjects); } else { assetLoader.ReportError("AssetBundle object: " + "scriptableLibrary.asset" + " not present or incorrect."); } }
public virtual GameObject InstantiateLibraryObject(LibraryObject libObj, Vector3 worldPos) { //Debug.Log("inst, "); GameObject go = libObj.Instantiate(worldPos); //Debug.Log("inst "+go.name); go.transform.SetParent(transform, true); ManipulableObject man = go.GetComponent <ManipulableObject>(); if (man == null && addManipulableBehaviorToInstances) { go.AddComponent <ManipulableObject>(); man = go.GetComponent <ManipulableObject>(); man.boxCollider = go.GetComponent <BoxCollider>(); man.VERTICAL_MOVEMENT_ENABLED = false; man.START_ENABLED = true; } Animator anim = go.GetComponentInChildren <Animator>(); if (anim != null) { Debug.Log("Object has an Animator"); } if (man != null) { man.worldObjects = this; } AddInstantiatedObject(go); SelectedObject = go; // Select it onInstantiatedObject.Invoke(go); return(go); }
public DataMessage(LibraryObject row) { data = new List <LibraryObject>(); data.Add(row); }
/// <summary> /// Efface un LibraryObject de MainLibrary /// </summary> /// <param name="item"></param> public void Delete_Library_Object(LibraryObject item) { mainLibrary.Delete(item); }
public override async Task <APIResponse> UpdateAnimeInLibrary(UserLoginInfo userInfo, LibraryObject libraryObject, IProgress <APIProgressReport> progress) { if (!userInfo.IsUserLoggedIn) { if (progress != null) { progress.Report(new APIProgressReport(100.0, "This user is not logged in", APIResponse.Failed)); } return(APIResponse.Failed); } if (libraryObject == null) { if (progress != null) { progress.Report(new APIProgressReport(100.0, "Please supply a valid LibraryObject", APIResponse.Failed)); } return(APIResponse.Failed); } if (libraryObject.Anime == null) { if (progress != null) { progress.Report(new APIProgressReport(100.0, "There is no valid AnimeObject attacked to the LibraryObject", APIResponse.Failed)); } return(APIResponse.Failed); } string compliantAnimeID = libraryObject.Anime.ID.ID.ConvertToAPIConpliantString(' ', '-'); HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, Service.CreateAPIServiceUri("/libraries/" + compliantAnimeID)); requestMessage.Headers.Add("accept", "application/json"); requestMessage.Content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("auth_token", userInfo.AuthToken), new KeyValuePair <string, string>("status", Converters.LibrarySectionConverter.LibrarySectionToString(libraryObject.Section)), new KeyValuePair <string, string>("privacy", Converters.PrivacySettingsConverter.PrivacySettingsToString(libraryObject.Private)), // Can be "public", "private" new KeyValuePair <string, string>("sane_rating_update", libraryObject.Rating.ToString()), // none = None Selected, 0-2 = Unhappy, 3 = Neutral, 4-5 = Happy //new KeyValuePair<string,string>("rewatching", (false.ToString()).ToLower()), new KeyValuePair <string, string>("rewatched_times", libraryObject.RewatchedTimes.ToString()), new KeyValuePair <string, string>("notes", libraryObject.Notes), new KeyValuePair <string, string>("episodes_watched", libraryObject.EpisodesWatched.ToString()), new KeyValuePair <string, string>("increment_episodes", (false.ToString()).ToLower()) }); HttpResponseMessage response = await APIWebClient.MakeAPICall(requestMessage); if (response.IsSuccessStatusCode) { if (progress != null) { progress.Report(new APIProgressReport(100.0, "Library Object Updated", APIResponse.Successful, APIResponse.Successful, APIResponse.Successful)); } return(APIResponse.Successful); } if (progress != null) { progress.Report(new APIProgressReport(100.0, "API Call wasn't successul", APIResponse.Failed)); } return(APIResponse.Failed); }
public abstract Task <APIResponse> UpdateAnimeInLibrary(UserLoginInfo userInfo, LibraryObject libraryObject, IProgress <APIProgressReport> progress);
public void Delete(LibraryObject toKill) { MasterList.Remove(toKill); saveLibrary(); }
/// <summary> /// Permet d'ajouter un item à la librairie /// </summary> /// <param name="toAdd"></param> public void AddLibraryObject(LibraryObject toAdd) { MasterList.Add(toAdd); saveLibrary(); }