public void Initialize(InitialCondition initialCondition) { title.text = $"Set {ConditionsController.active.conditionViews.Count}"; SetInitialConditionUIValues(initialCondition); presets.ClearOptions(); List <Dropdown.OptionData> options = new List <Dropdown.OptionData>(); options.Add(new Dropdown.OptionData("-")); foreach (string key in ConditionsController.active.initialConditionsPresets.Keys) { options.Add(new Dropdown.OptionData(key)); } presets.AddOptions(options); int j = 0; int presetValue = 0; foreach (string key in ConditionsController.active.initialConditionsPresets.Keys) { if (AreInitialConditionsEquals(ConditionsController.active.initialConditionsPresets[key], initialCondition)) { presetValue = j + 1; } j++; } // Debug.Log(initialCondition.angularVelocity == ConditionsController.active.initialConditionsPresets["Rotating Disc"].angularVelocity); presets.value = presetValue; }
public void Add(InitialCondition initialCondition) { GameObject instance = Instantiate(conditionPrefab, conditionInstanceParent); instance.SetActive(true); ConditionView conditionView = instance.GetComponent <ConditionView>(); conditionViews.Add(conditionView); conditionView.Initialize(initialCondition); }
public void DropdownUpdate() { string key = presets.options[presets.value].text; if (!ConditionsController.active.initialConditionsPresets.ContainsKey(key)) { return; } InitialCondition initialCondition = ConditionsController.active.initialConditionsPresets[key]; SetInitialConditionUIValues(initialCondition); }
void SetInitialConditionUIValues(InitialCondition initialCondition) { numberOfParticles.text = initialCondition.numberOfParticles.ToString(); centerX.text = initialCondition.center.x.ToString(); centerY.text = initialCondition.center.y.ToString(); centerZ.text = initialCondition.center.z.ToString(); radius.text = initialCondition.radius.ToString(); shapeElipsoidX.text = initialCondition.shapeElipsoid.x.ToString(); shapeElipsoidY.text = initialCondition.shapeElipsoid.y.ToString(); shapeElipsoidZ.text = initialCondition.shapeElipsoid.z.ToString(); turbulenceStrength.text = initialCondition.turbulenceStrength.ToString(); turbulenceElipsoidX.text = initialCondition.turbulenceElipsoid.x.ToString(); turbulenceElipsoidY.text = initialCondition.turbulenceElipsoid.y.ToString(); turbulenceElipsoidZ.text = initialCondition.turbulenceElipsoid.z.ToString(); angularVelocity.text = initialCondition.angularVelocity.ToString(); seed.text = initialCondition.seed.ToString(); }
bool AreInitialConditionsEquals(InitialCondition conditionA, InitialCondition conditionB) { return (conditionA.numberOfParticles == conditionB.numberOfParticles && conditionA.center.x == conditionB.center.x && conditionA.center.y == conditionB.center.y && conditionA.center.z == conditionB.center.z && conditionA.radius == conditionB.radius && conditionA.shapeElipsoid.x == conditionB.shapeElipsoid.x && conditionA.shapeElipsoid.y == conditionB.shapeElipsoid.y && conditionA.shapeElipsoid.z == conditionB.shapeElipsoid.z && conditionA.turbulenceStrength == conditionB.turbulenceStrength && conditionA.turbulenceElipsoid.x == conditionB.turbulenceElipsoid.x && conditionA.turbulenceElipsoid.y == conditionB.turbulenceElipsoid.y && conditionA.turbulenceElipsoid.z == conditionB.turbulenceElipsoid.z && conditionA.angularVelocity == conditionB.angularVelocity && conditionA.seed == conditionB.seed); }