Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How can i get dynamic variable with serialization?

Discussion in '2D' started by TelloSoft, Feb 28, 2020.

  1. TelloSoft

    TelloSoft

    Joined:
    Oct 29, 2019
    Posts:
    17
    How can i achieve this in my script as (Unity Analytics Event) script have dynamic variable system



    In the above attached image the serialized field is highlighted and in that script i have option to assign dynamic variable. so i want same for my own script. I have searched it already on Stackoverflow and unity forum but i can't find!
    The above attached image is of a plugin (Unity Analytics Event) & when i attached that script to a game object i have option to assign a dynamic variable from inspector as shown in above attached image so i want same thing for my own script. how can i achieve same for my own script I have tried custom Unity event but failed.

    Thank you very much in advance!
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
  3. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Actually nevermind, there is a much easier way. Just make a serializable (or public) enum with the values you want, then make a serialized field for that enum.

    upload_2020-2-28_16-40-37.png

    upload_2020-2-28_16-41-6.png