Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How do I create a curve asset?

Discussion in 'Animation' started by rell023, Apr 20, 2023.

  1. rell023

    rell023

    Joined:
    Mar 29, 2023
    Posts:
    20
    Not sure if this is the right place to ask this, I can find everything in the internet on animation curves except for how to create the asset to begin with. Where do I find the option to create a curve? There is absolutely nothing in the create menu. I am trying to utilize a curve to map values onto over a y axis in an asset multiple scripts can reference and read. Am I misunderstanding how curves work in Unity? Or perhaps I'm just frustrated and skipping over stuff.

    Thanks for your time!
     
  2. Yuchen_Chang

    Yuchen_Chang

    Joined:
    Apr 24, 2020
    Posts:
    125
    Curve is plain C# object (like string), so if you want to serialize it, you'll have to make a MonoBehaviour or ScriptableObject to contain it.

    Simple ScriptableObject sample:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. [CreateAssetMenu(fileName = "CurveContainer", menuName = "ScriptableObjects/CurveContainer")]
    4. public class CurveContainerScriptableObject : ScriptableObject
    5. {
    6.     public AnimationCurve curve;
    7.     // or
    8.     public AnimationCurve[] curves;
    9. }
     
  3. rell023

    rell023

    Joined:
    Mar 29, 2023
    Posts:
    20
    Ohh so its not a data asset like in UE, that makes more sense now, thanks for your answer. I will try this out.
     
  4. rell023

    rell023

    Joined:
    Mar 29, 2023
    Posts:
    20
    That worked perfectly! Thanks!