using System; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace UnityEditor.VFX.Operator { [VFXHelpURL("Operator-Discretize")] [VFXInfo(category = "Math/Clamp")] class Discretize : VFXOperatorNumericUnified, IVFXOperatorNumericUnifiedConstrained { public class InputProperties { [Tooltip("The value to be discretized.")] public float a = 0.0f; [Min(0.000001f), Tooltip("The granularity.")] public float b = 1.0f; } protected override sealed string operatorName { get { return "Discretize"; } } public IEnumerable slotIndicesThatMustHaveSameType { get { return Enumerable.Range(0, 2); } } public IEnumerable slotIndicesThatCanBeScalar { get { yield return 1; } } protected sealed override ValidTypeRule typeFilter { get { return ValidTypeRule.allowEverythingExceptIntegerAndDirection; } } protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression) { return new[] { VFXOperatorUtility.Discretize(inputExpression[0], inputExpression[1]) }; } } }