internal static void DisplayGraphParameters(LayoutElementsContainer layout, GraphParameterData[] data, GetGraphParameterDelegate getter, SetGraphParameterDelegate setter, ValueContainer values, GetGraphParameterDelegate defaultValueGetter = null, CustomPropertySpawnDelegate propertySpawn = null) { GroupElement lastGroup = null; for (int i = 0; i < data.Length; i++) { ref var e = ref data[i]; if (!e.IsPublic) { continue; } var tag = e.Tag; var parameter = e.Parameter; LayoutElementsContainer itemLayout; // Editor Display if (e.Display?.Group != null) { if (lastGroup == null || lastGroup.Panel.HeaderText != e.Display.Group) { lastGroup = layout.Group(e.Display.Group); lastGroup.Panel.Open(false); } itemLayout = lastGroup; } else { lastGroup = null; itemLayout = layout; } // Space if (e.Space != null) { itemLayout.Space(e.Space.Height); } // Header if (e.Header != null) { itemLayout.Header(e.Header); } // Values container var valueType = new ScriptType(e.Type); var valueContainer = new CustomValueContainer(valueType, (instance, index) => getter(values[index], parameter, tag), (instance, index, value) => setter(values[index], value, parameter, tag), e.Attributes); for (int j = 0; j < values.Count; j++) { valueContainer.Add(getter(values[j], parameter, tag)); } // Default value if (defaultValueGetter != null) { valueContainer.SetDefaultValue(defaultValueGetter(values[0], parameter, tag)); } // Prefab value if (values.HasReferenceValue) { var referenceValue = getter(values.ReferenceValue, parameter, tag); if (referenceValue != null) { valueContainer.SetReferenceValue(referenceValue); } } if (propertySpawn == null) { itemLayout.Property(e.DisplayName, valueContainer, null, e.Tooltip?.Text); } else { propertySpawn(itemLayout, valueContainer, ref e); } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); _isValid = IsValid; if (!_isValid) { return; } // Show all effect parameters grouped by the emitter track name var effect = (ParticleEffect)Values[0]; var groups = layout.Group("Parameters"); groups.Panel.Open(false); var parameters = effect.Parameters; var parametersGroups = parameters.GroupBy(x => x.EmitterIndex); foreach (var parametersGroup in parametersGroups) { var trackName = parametersGroup.First().TrackName; var group = groups.Group(trackName); group.Panel.Open(false); foreach (var parameter in parametersGroup) { if (!parameter.IsPublic) { continue; } var parameterName = parameter.Name; var value = parameter.Value; var valueType = Utilities.Utils.GetGraphParameterValueType(parameter.ParamType); // Parameter value accessor var valueContainer = new CustomValueContainer( valueType, value, (instance, index) => ((ParticleEffect)Values[index]).GetParameterValue(trackName, parameterName), (instance, index, o) => ((ParticleEffect)Values[index]).SetParameterValue(trackName, parameterName, o) ); for (int index = 1; index < Values.Count; index++) { valueContainer.Add(((ParticleEffect)Values[index]).GetParameterValue(trackName, parameterName)); } // Default value valueContainer.SetDefaultValue(parameter.DefaultValue); // Prefab value if (Values.HasReferenceValue) { var referenceEffect = (ParticleEffect)Values.ReferenceValue; var referenceParameter = referenceEffect.GetParameter(trackName, parameterName); if (referenceParameter != null) { valueContainer.SetReferenceValue(referenceParameter.Value); } } group.Property(parameter.Name, valueContainer); } } }