private void NextSlide(bool advance) { if (advance) { currentSlide++; if (currentSlide >= maxSlide) { currentSlide = 0; } } else { currentSlide--; if (currentSlide < 0) { currentSlide = maxSlide - 1; } } Debug.Log(eqnNames[currentSlide]); chaoticMotion.selectedEqn = currentSlide; slideLabel.text = eqnNames[currentSlide]; // re-center position/camera transform.position = Vector3.zero; cameraBoom.transform.rotation = initialRotation; chaoticMotion.timeZoom = eqns[currentSlide].GetSlideshowSpeed(); chaoticMotion.Init(); if (chaosTrail != null) { chaosTrail.Init(); } }
// Use this for initialization void Start() { int count = ChaosEqnFactory.GetEquations().Count; int gridSize = Mathf.CeilToInt(Mathf.Sqrt((float)count)); int row = 0; int col = 0; int materialCount = 0; // set position in grid if (materials.Length == 0) { Debug.Log("Need to specify materials"); } Vector3 origin = new Vector3(-gridSpacing * gridSize / 2, gridSpacing * gridSize / 2, 0f); for (int i = 0; i < count; i++) { Vector3 p = transform.position + origin; p.x += gridSpacing * row; p.y -= gridSpacing * col; GameObject chaosSystem = Instantiate <GameObject>(chaosPrefab, p, Quaternion.identity); chaosSystem.transform.parent = transform; ChaoticMotion cm = chaosSystem.GetComponentInChildren <ChaoticMotion>(); cm.selectedEqn = i; cm.timeZoom = cm.GetEquation().GetSlideshowSpeed(); cm.Init(); // Use the specified materials to color the attractor trails differently foreach (LineRenderer lr in cm.GetComponentsInChildren <LineRenderer>()) { lr.sharedMaterial = materials[materialCount]; } Text t = chaosSystem.GetComponentInChildren <Text>(); t.text = cm.GetEquation().GetName(); // advance to next grid slot row++; if (row >= gridSize) { row = 0; col++; } materialCount++; if (materialCount >= materials.Length) { materialCount = 0; } Debug.Log("mc= " + materialCount); } }
// Use this for initialization void Start() { nextSlideTime = Time.time + timer; eqns = ChaosEqnFactory.GetEquations(); maxSlide = eqns.Count; eqnNames = new string[maxSlide]; int index = 0; foreach (ChaosEqn eqn in eqns) { eqnNames[index] = eqn.GetName(); index++; } chaoticMotion = GetComponent <ChaoticMotion>(); chaoticMotion.selectedEqn = currentSlide; chaoticMotion.timeZoom = eqns[currentSlide].GetSlideshowSpeed(); slideLabel.text = eqnNames[currentSlide]; chaoticMotion.Init(); // get trail (if present) chaosTrail = GetComponentInChildren <ChaosTrail>(); initialRotation = transform.rotation; }