public override void SetUpPlayArea(BAnchorInformation[] bAnchorInformation) { // TODO: Wait for some frames ? if (ARE_EQUAL(bAnchorInformation.Length, 2)) { PlayAreaState = EPlayAreaState.SETTING_ANCHORS; // Spawn BAnchors for (int i = 0; i < 2; i++) { PlayAreaBAnchor playAreaBAnchor = AddNewChildBAnchor(false); if (IS_NOT_NULL(playAreaBAnchor)) { playAreaBAnchor.gameObject.name += "_" + (i + 1); playAreaBAnchor.SetTransformedPosition(bAnchorInformation[i].TransformedPosition); playAreaBAnchor.SetTransformedRotation(bAnchorInformation[i].TransformedRotation); } } // Finalize setAnchorsCount = 2; SetExtentPoints(); DrawPlayAreaExtensions(); FinalizePlayAreaSetup(); } }
protected virtual PlayAreaBAnchor AddNewChildBAnchor(bool directlyStartPlacing = true) { if (IS_NOT_NULL(playAreaBAnchorPrefab) && IS_NULL(CurrentPlayAreaBAnchorBeingPlaced)) { PlayAreaBAnchor spawnedPlayAreaBAnchor = Instantiate(playAreaBAnchorPrefab); if (IS_NOT_NULL(spawnedPlayAreaBAnchor)) { spawnedPlayAreaBAnchor.transform.parent = transform; PlayAreaBAnchors.Add(spawnedPlayAreaBAnchor); LogConsole("Adding new play area BAnchor : " + PlayAreaBAnchors.Count); spawnedPlayAreaBAnchor.StartedPlacing += On_SpawnedPlayAreaBAnchor_StartedPlacing; spawnedPlayAreaBAnchor.EndedPlacing += On_SpawnedPlayAreaBAnchor_EndedPlacing; if (directlyStartPlacing) { spawnedPlayAreaBAnchor.OnStartPlacing(); } return(spawnedPlayAreaBAnchor); } } return(null); }
private void StartSettingFirstAnchor() { PlayAreaBAnchor playAreaBAnchor = AddNewChildBAnchor(); if (IS_NOT_NULL(playAreaBAnchor)) { playAreaBAnchor.gameObject.name += "_1"; } }
protected virtual void On_SpawnedPlayAreaBAnchor_StartedPlacing(PlayAreaBAnchor playAreaBAnchor) { if (IS_NOT_NULL(playAreaBAnchor) && IS_VALUE_CONTAINED(PlayAreaBAnchors, playAreaBAnchor) && IS_NULL(CurrentPlayAreaBAnchorBeingPlaced)) { CurrentPlayAreaBAnchorBeingPlaced = playAreaBAnchor; } }
private void On_BAnchorCursorPlacer_EndedPlacing(BAnchor bAnchor) { PlayAreaBAnchor playAreaBAnchor = (PlayAreaBAnchor)bAnchor; if (IS_NOT_NULL(playAreaBAnchor) && (ARE_EQUAL(playAreaBAnchor, this))) { InvokeEventIfBound(EndedPlacing, this); } }
protected virtual void On_SpawnedPlayAreaBAnchor_EndedPlacing(PlayAreaBAnchor playAreaBAnchor) { if (IS_NOT_NULL(playAreaBAnchor) && IS_VALUE_CONTAINED(PlayAreaBAnchors, playAreaBAnchor) && ARE_EQUAL(CurrentPlayAreaBAnchorBeingPlaced, playAreaBAnchor)) { int index = PlayAreaBAnchors.IndexOf(playAreaBAnchor); InvokeEventIfBound(NewPlayAreaBAnchorSet, playAreaBAnchor, index); CurrentPlayAreaBAnchorBeingPlaced = null; } }
private void StartSettingSecondAnchor() { PlayAreaBAnchor playAreaBAnchor = AddNewChildBAnchor(); if (IS_NOT_NULL(playAreaBAnchor) && PlayAreaBAnchors.Count > 0 && IS_NOT_NULL(PlayAreaBAnchors[0])) { playAreaBAnchor.gameObject.name += "_2"; playAreaBAnchor.DisablePlacementRotation(); playAreaBAnchor.transform.rotation = PlayAreaBAnchors[0].transform.rotation; } }
private IEnumerator SetTestPlayAreaCoroutine() { ARManager.Instance.SetupPlayArea(); yield return(new WaitForEndOfFrame()); ARCursor.Instance.transform.position = new Vector3(0.0f, 0.0f, 1.0f); PlayAreaBAnchor playAreaBAnchor = FindObjectOfType <PlayAreaBAnchor>(); if (IS_NOT_NULL(playAreaBAnchor)) { playAreaBAnchor.EndPlacing(); } yield return(new WaitForEndOfFrame()); ARCursor.Instance.transform.position = new Vector3(3.5f, 0.0f, 8.6f); }
protected virtual bool RemoveChildBAnchor(PlayAreaBAnchor playAreaBAnchor) { if (IS_NOT_NULL(playAreaBAnchor)) { if (IS_VALUE_CONTAINED(PlayAreaBAnchors, playAreaBAnchor)) { playAreaBAnchor.StartedPlacing -= On_SpawnedPlayAreaBAnchor_StartedPlacing; playAreaBAnchor.EndedPlacing -= On_SpawnedPlayAreaBAnchor_EndedPlacing; PlayAreaBAnchors.Remove(playAreaBAnchor); if (CurrentPlayAreaBAnchorBeingPlaced == playAreaBAnchor) { CurrentPlayAreaBAnchorBeingPlaced = null; } Destroy(playAreaBAnchor.gameObject); return(true); } LogConsoleWarning("Couldn't remove the given PlayAreaBAnchor : " + playAreaBAnchor.gameObject.name); } return(false); }
protected override void On_SpawnedPlayAreaBAnchor_EndedPlacing(PlayAreaBAnchor playAreaBAnchor) { base.On_SpawnedPlayAreaBAnchor_EndedPlacing(playAreaBAnchor); switch (setAnchorsCount) { case 0: setAnchorsCount = 1; LogConsole("First anchor set. Setting second anchor..."); StartSettingSecondAnchor(); break; case 1: setAnchorsCount = 2; LogConsole("Second anchor set. Finalizing setup."); FinalizePlayAreaSetup(); break; default: LogConsoleWarning("Play Area already set up !"); break; } }
protected override void OnValidate() { base.OnValidate(); if (CanValidate() == false) { return; } if (myLineRenderer == null) { myLineRenderer = GetComponent <LineRenderer>(); if (myLineRenderer) { myLineRenderer.SetPositions(new Vector3[0]); } } if (playAreaBAnchorPrefab == null) { playAreaBAnchorPrefab = Resources.Load <PlayAreaBAnchor>(BConsts.PATH_AR_PlayAreaBAnchor); } }
protected override void On_SpawnedPlayAreaBAnchor_StartedPlacing(PlayAreaBAnchor playAreaBAnchor) { base.On_SpawnedPlayAreaBAnchor_StartedPlacing(playAreaBAnchor); }