public void AddOptions(GameObject SelectedObject, ObjectEditUI ObjectEdit) { var material = SelectedObject?.GetComponentInChildren <MeshRenderer>()?.material; if (material == null) { return; } var settings = ObjectEdit.AddColorTintSettings(); var expandable = settings.GetComponent <Expandable>(); var colorTintExpandable = settings.GetComponent <ColorTintExpandable>(); if (colorTintExpandable == null) { return; } var buttons = expandable.PropertiesListContent.GetComponentsInChildren <Button>(); foreach (var button in buttons) { button.onClick.AddListener(() => ColorClicked(SelectedObject, button.gameObject.GetComponent <Image>().color)); } }
public void AddOptions(GameObject SelectedObject, ObjectEditUI ObjectEdit) { Animator = SelectedObject.GetComponentInChildren <Animator>(); if (Animator == null) { return; } if (Animator.runtimeAnimatorController == null) { return; } if (!Animator.runtimeAnimatorController.animationClips.Any()) { return; } if (Animator.avatar == null) { return; } Animations = Animator.runtimeAnimatorController.animationClips; var settings = ObjectEdit.AddAvatarAnimatorSettings(); var expandable = settings.GetComponent <Expandable>(); var avatarAnimatorExpandable = settings.GetComponent <AvatarAnimatorExpandable>(); foreach (var animation in Animations) { AddListItem(avatarAnimatorExpandable.ListItemPrefab, expandable.PropertiesListContent.transform, animation); } }
public void AddOptions(GameObject SelectedObject, ObjectEditUI ObjectEdit) { //if (ObjectMovementController.Instance.SelectedObjectLayerInfo == null) return; var grindables = SelectedObject.GetPrefab().GetChildrenOnLayer("Grindable"); bool hasGrindables = grindables != null && grindables.Any(); var copings = SelectedObject.GetPrefab().GetChildrenOnLayer("Coping"); bool hasCoping = copings != null && copings.Any(); if (!hasGrindables && !hasCoping) { return; } var grindableExpandable = ObjectEdit.AddGrindableSettings(); var expandable = grindableExpandable.GetComponent <GrindableSettingsExpandable>(); var spawnable = SelectedObject.GetSpawnableFromSpawned() ?? SelectedObject.GetSpawnable(); if (spawnable == null) { return; } expandable.GrindablesToggle.Toggle.interactable = hasGrindables; if (hasGrindables) { expandable.GrindablesToggle.Toggle.isOn = GrindableEnabled; expandable.GrindablesToggle.Toggle.interactable = true; expandable.GrindablesToggle.Toggle.onValueChanged.AddListener((isOn) => { GrindableEnabled = isOn; DisableLayer(spawnable.PrefabLayerInfo, "Grindable", isOn); }); } expandable.CopingToggle.Toggle.interactable = hasCoping; if (hasCoping) { expandable.CopingToggle.Toggle.isOn = CopingEnabled; expandable.CopingToggle.Toggle.interactable = true; expandable.CopingToggle.Toggle.onValueChanged.AddListener((isOn) => { CopingEnabled = isOn; DisableLayer(spawnable.PrefabLayerInfo, "Coping", isOn); }); } }
public void AddOptions(GameObject SelectedObject, ObjectEditUI ObjectEdit) { this.SelectedObject = SelectedObject; var spawnable = SelectedObject.GetSpawnable(); var editStyleController = spawnable.Settings.FirstOrDefault(x => x is EditStyleController) as EditStyleController; if (editStyleController?.Styles == null || !editStyleController.Styles.Any()) { return; } var newExpandable = ObjectEdit.AddStyleSettings(); var expandable = newExpandable.GetComponent <Expandable>(); var styleExpandable = newExpandable.GetComponent <StyleSettingsExpandable>(); var styleController = spawnable.Prefab.GetComponent <XLStyleController>(); string style = styleController?.Style; string subStyle = styleController?.SubStyle; string name = style; if (!string.IsNullOrEmpty(subStyle)) { name += $" / {subStyle}"; } AddListItem(styleExpandable.ListItemPrefab, expandable.PropertiesListContent.transform, spawnable, name); foreach (var altStyle in editStyleController.Styles.Where(x => x != spawnable)) { styleController = altStyle.Prefab.GetComponent <XLStyleController>(); style = styleController?.Style; subStyle = styleController?.SubStyle; name = style; if (!string.IsNullOrEmpty(subStyle)) { name += $" / {subStyle}"; } AddListItem(styleExpandable.ListItemPrefab, expandable.PropertiesListContent.transform, altStyle, name); } }
public void AddOptions(GameObject SelectedObject, ObjectEditUI ObjectEdit) { var generalExpandable = ObjectEdit.AddGeneralSettings(); var expandable = generalExpandable.GetComponent <GeneralSettingsExpandable>(); if (expandable == null) { return; } expandable.HideInReplays.Toggle.isOn = HideInReplays; expandable.HideInReplays.Toggle.onValueChanged.AddListener((isOn) => { HideInReplays = isOn; if (SelectedObject?.GetSpawnableFromSpawned()?.Settings?.FirstOrDefault(x => x is EditGeneralController) is EditGeneralController general) { general.HideInReplays = HideInReplays; } }); }
public void AddOptions(GameObject SelectedObject, ObjectEditUI ObjectEdit) { var rigidBodies = SelectedObject.GetPrefab().GetComponentsInChildren <Rigidbody>(true); if (rigidBodies == null || !rigidBodies.Any()) { return; } var rigidbodyExpandable = ObjectEdit.AddRigidbodySettings(); var expandable = rigidbodyExpandable.GetComponent <RigidbodySettingsExpandable>(); var spawnable = SelectedObject.GetSpawnableFromSpawned() ?? SelectedObject.GetSpawnable(); if (spawnable == null) { return; } expandable.EnablePhysicsToggle.Toggle.isOn = EnablePhysics; expandable.EnablePhysicsToggle.Toggle.interactable = true; expandable.EnablePhysicsToggle.Toggle.onValueChanged.AddListener((isOn) => { EnablePhysics = isOn; ToggleRigidBodies(SelectedObject, isOn); }); expandable.EnableRespawnRecallToggle.Toggle.isOn = EnableRespawnRecall; expandable.EnableRespawnRecallToggle.Toggle.interactable = true; expandable.EnableRespawnRecallToggle.Toggle.onValueChanged.AddListener((isOn) => { EnableRespawnRecall = isOn; RecallPosition = EnableRespawnRecall ? SelectedObject.transform.position : Vector3.zero; RecallRotation = EnableRespawnRecall ? SelectedObject.transform.rotation : Quaternion.identity; }); }
public void AddOptions(GameObject SelectedObject, ObjectEditUI ObjectEdit) { var lights = SelectedObject.GetComponentsInChildren <Light>(true); if (lights != null && lights.Any()) { var light = lights.First(); var hdrpLight = light.GetComponent <HDAdditionalLightData>(); var lightExpandable = ObjectEdit.AddLightSettings(); var expandable = lightExpandable.GetComponent <LightSettingsExpandable>(); Enabled = light.enabled; expandable.EnabledToggle.Toggle.onValueChanged.AddListener((isOn) => { Enabled = isOn; foreach (var lightToEdit in lights) { lightToEdit.GetComponent <HDAdditionalLightData>().enabled = isOn; lightToEdit.enabled = isOn; } }); #region Intensity slider hdrpLight.lightUnit = LightUnit.Ev100; float currentIntensity = Mathf.Clamp(hdrpLight.intensity, ev100Min, ev100Max); float sliderValue = ((currentIntensity - ev100Min) / (ev100Max - ev100Min)) * numSteps; Intensity = sliderValue; Unit = LightUnit.Ev100; expandable.IntensitySlider.Slider.value = sliderValue; float labelText = ev100Min + ((sliderValue / numSteps) * (ev100Max - ev100Min)); expandable.IntensitySlider.Value.SetText(labelText.ToString("N")); expandable.IntensitySlider.Slider.onValueChanged.AddListener((intensity) => { foreach (var lightToEdit in lights) { var hdrpLightToEdit = lightToEdit.GetComponent <HDAdditionalLightData>(); float newIntensity = ev100Min + ((intensity / numSteps) * (ev100Max - ev100Min)); expandable.IntensitySlider.Value.SetText(newIntensity.ToString("N")); Intensity = newIntensity; Unit = LightUnit.Ev100; hdrpLightToEdit.SetIntensity(newIntensity, LightUnit.Ev100); } }); #endregion #region Range slider float currentRange = Mathf.Clamp(hdrpLight.range, rangeMin, rangeMax); Range = currentRange; float rangeSliderValue = ((currentRange - rangeMin) / (rangeMax - rangeMin)) * numRangeSteps; expandable.RangeSlider.Slider.value = rangeSliderValue; expandable.RangeSlider.Value.SetText(rangeSliderValue.ToString("N")); expandable.RangeSlider.Slider.onValueChanged.AddListener((range) => { foreach (var lightToEdit in lights) { float newRange = rangeMin + ((range / numRangeSteps) * (rangeMax - rangeMin)); Range = newRange; expandable.RangeSlider.Value.SetText(newRange.ToString("N")); lightToEdit.GetComponent <HDAdditionalLightData>().SetRange(newRange); } }); #endregion #region Angle slider if (hdrpLight.type != HDLightType.Spot) { Angle = null; expandable.AngleSlider.Slider.interactable = false; } else { float spotAngle = Mathf.Clamp(light.spotAngle, angleMin, angleMax); Angle = spotAngle; float angleSliderValue = ((spotAngle - angleMin) / (angleMax - angleMin)) * numAngleSteps; expandable.AngleSlider.Slider.value = angleSliderValue; expandable.AngleSlider.Value.SetText($"{(int)angleSliderValue}°"); expandable.AngleSlider.Slider.onValueChanged.AddListener((angle) => { foreach (var lightToEdit in lights) { float newSpotAngle = angleMin + (((angle - angleMin) / numAngleSteps) * (angleMax - angleMin)); lightToEdit.spotAngle = newSpotAngle; Angle = newSpotAngle; expandable.AngleSlider.Value.SetText($"{(int)newSpotAngle}°"); } }); } #endregion #region Color sliders Color = new Vector3(hdrpLight.color.r, hdrpLight.color.g, hdrpLight.color.b); expandable.ColorSliders.XSlider.Slider.value = hdrpLight.color.r; expandable.ColorSliders.XSlider.Value.SetText(hdrpLight.color.r.ToString("N")); expandable.ColorSliders.YSlider.Slider.value = hdrpLight.color.g; expandable.ColorSliders.YSlider.Value.SetText(hdrpLight.color.g.ToString("N")); expandable.ColorSliders.ZSlider.Slider.value = hdrpLight.color.b; expandable.ColorSliders.ZSlider.Value.SetText(hdrpLight.color.b.ToString("N")); expandable.ColorSliders.onValueChanged += (color) => { Color = color; foreach (var lightToEdit in lights) { lightToEdit.GetComponent <HDAdditionalLightData>().color = new Color(color.x, color.y, color.z); expandable.ColorSliders.XSlider.Value.SetText(color.x.ToString("N")); expandable.ColorSliders.YSlider.Value.SetText(color.y.ToString("N")); expandable.ColorSliders.ZSlider.Value.SetText(color.z.ToString("N")); } }; #endregion } }