// Use this for initialization void Start() { if (prefab == null) { Debug.Log("No prefab in Script OuterLinesForOrientation set."); } m_tokenPosition = TokenPosition.Instance; m_settings = Settings.Instance; m_camera = GameObject.FindGameObjectWithTag(m_settings.mainCameraTag).GetComponent <Camera>(); //Instantiates variables for spawning top and bottom prefabs float prefabYBounds = prefab.GetComponent <SpriteRenderer>().bounds.size.y / 2; float topYPos = -5 + prefabYBounds + Camera.main.ScreenToWorldPoint(new Vector3(0, Camera.main.pixelHeight / 2 + m_settings.heightOffSetInPx_bottom, 0)).y; float bottomYPos = 5 - prefabYBounds; float xPos; //spawns number of beats Outer_Line_For_Orientation prefabs in loop for Top and Bottom for (int i = 0; i < m_settings.beats + 1; i++) { xPos = m_tokenPosition.GetXPosForBeat(i); GameObject currentGO = Instantiate(prefab, new Vector3(xPos, topYPos, 0), Quaternion.identity); currentGO.transform.parent = this.transform; currentGO = Instantiate(prefab, new Vector3(xPos, bottomYPos, 0), Quaternion.identity); currentGO.transform.parent = this.transform; } //Instantiates variables for spawning and updating left and right lines on loopBars startLoopBar = GameObject.Find(m_settings.startBarLoop).transform; endLoopBar = GameObject.Find(m_settings.endtBarLoop).transform; int numberOfTunes = m_settings.tunes; leftLines = new Transform[numberOfTunes + 1]; rightLines = new Transform[numberOfTunes + 1]; float yPos; //spawns number of tunes Outer_Line_For_Orientation prefabs in loop for left and right for (int i = 0; i < m_settings.tunes; i++) { yPos = m_tokenPosition.GetYPosForTune(i); leftLines[i] = Instantiate(prefab, new Vector3(startLoopBar.transform.position.x - prefabYBounds, yPos, 0), Quaternion.Euler(new Vector3(0, 0, 90))).transform; //prefabYBounds can be used, because the sprite got turned by 90 degrees leftLines[i].transform.parent = startLoopBar.transform; rightLines[i] = Instantiate(prefab, new Vector3(endLoopBar.transform.position.x + prefabYBounds, yPos, 0), Quaternion.Euler(new Vector3(0, 0, 90))).transform; rightLines[i].transform.parent = endLoopBar.transform; } }
void Start() { m_settings = Settings.Instance; GameObject[] loopMarkers = GameObject.FindGameObjectsWithTag(m_settings.loopMarkerTag); int counter = 0; foreach (GameObject loopMarker in loopMarkers) { if (loopMarker.GetComponent <LoopController>().startMarker) { counter++; } //save other LoopMarker if (loopMarker.GetComponent <LoopController>().startMarker != this.startMarker) { otherLoopMarker = loopMarker; } if (counter > 1) { Debug.LogError("More than one Loop Start Gameobject defined. Must be exactely one."); break; } } if (counter == 0) { Debug.LogError("No Loop Start GameObject defined. Must be exactely one."); } if (ghostPrefab == null) { Debug.LogError("No ghost prefab defined."); } m_tuioManager = TuioManager.Instance; m_tokenPosition = TokenPosition.Instance; m_locationBar = FindObjectsOfType <LocationBar>()[0]; m_fiducialController = this.GetComponent <FiducialController>(); transform.position = new Vector3(startMarker ? m_tokenPosition.GetXPosForBeat(0) : m_tokenPosition.GetXPosForBeat(16), transform.position.y, transform.position.z); newPos = transform.position; }