Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] VFX PropertyBinder #445

Open
lgarczyn opened this issue Nov 14, 2023 · 1 comment
Open

[FEATURE] VFX PropertyBinder #445

lgarczyn opened this issue Nov 14, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@lgarczyn
Copy link

lgarczyn commented Nov 14, 2023

Is your feature request related to a problem? Please describe.

Right now, there are no easy interactions possible between VFX components and unity atoms.

Describe the solution you'd like

The VFX packages provides a very handy and powerful PropertyBinder system that makes linking VFX properties to things like transforms or colliders extremely easy.

It would be dead simple to add a package to atoms to implement binders for most atom types:

using UnityAtoms.BaseAtoms;
using UnityEngine;
using UnityEngine.VFX;
using UnityEngine.VFX.Utility;

namespace Atoms.VFXBinders
{
  [VFXBinder("Atoms/Float")]
  public class VFXFloatReferenceBinder : VFXBinderBase
  {
    [VFXPropertyBinding("System.Single")]
    [SerializeField] ExposedProperty property;
    [SerializeField] FloatReference value;

    public override bool IsValid(VisualEffect    component)
    {
      return !value.IsUnassigned && component.HasFloat(property);
    }

    public override void UpdateBinding(VisualEffect component)
    {
      component.SetFloat(property, value);
    }
  }
}

Previous ugly solution:

image

New cool solution:

image

@lgarczyn lgarczyn added the enhancement New feature or request label Nov 14, 2023
@lgarczyn
Copy link
Author

Also, currently there is no way to get a pretty name for a reference, so I'm stuck with this

    public override string ToString()
    {
      string valueName = value.IsUnassigned ? "null" : $"{AtomReferenceUsage.DisplayName(value.Usage)} {value.Value}";
      return $"Float : '{property}' -> {valueName}";
    }

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant