Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Updating property script value from another script in edit mode

Discussion in 'Scripting' started by fulvioKidloom, Oct 13, 2017.

  1. fulvioKidloom

    fulvioKidloom

    Joined:
    Feb 20, 2017
    Posts:
    54
    Hi, I have a builder script that I run in editor mode to set player settings.

    My issue is this:

    I have a script in a game object in the main scene.
    I need to change a property value from that script.

    I did this from my builder script

    Code (CSharp):
    1. AssetDatabase.StartAssetEditing();
    2. AppManager.Instance.appId = appId;
    3. AssetDatabase.StopAssetEditing();
    4. AssetDatabase.SaveAssets ();
    Note: AppManager is a MonoBehavior - Singleton Class that is added as component in the game object.
    Note 2: This AppManager class is used in the project so I can set ExecuteInEditMode tag

    I see in the editor that the property was changed to the value.

    But, when I run the project (pressed play mode button) the value of that property is reverted automatically to the previous value. Any change was taken

    I hope you can understand me.

    Any help?

    Thanks
     
    Last edited: Oct 13, 2017
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201