Search Unity

Feedback Values in Editor are reset When Platform Switching

Discussion in 'Editor & General Support' started by makaka-org, Mar 19, 2020.

  1. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,026
    I have next code on Prefab with declaring variables relevant only in Editor but these variables are different for iOS & Android. So variables are assigned in Editor.

    When Switching between Platforms in Editor then values which set in Editor before are reset.
    Is it normal behavior or Bug?

    If it's normal, why it happens and how I can achieve my goal when values are not reset when Switching.

    I use Unity 2019.3.5f1

    I submitted Bug Report, Please Vote, Guys:
    https://issuetracker.unity3d.com/is...-reset-in-the-editor-when-switching-platforms

    Code (CSharp):
    1.  
    2. #if UNITY_EDITOR
    3.  
    4. #if UNITY_ANDROID
    5.  
    6.     [SerializeField]
    7.     private Mesh mesh;
    8.  
    9.     [SerializeField]
    10.     private Vector3 pos;
    11.  
    12. #elif UNITY_IOS
    13.  
    14.     [SerializeField]
    15.     private float number;
    16.  
    17.     [SerializeField]
    18.     private int index;
    19.  
    20. #endif
    21.  
    22. #endif
    23.  
     
    Last edited: Mar 20, 2020
  2. antonsem

    antonsem

    Joined:
    Dec 13, 2012
    Posts:
    18
    When you switch platforms the code is recompiled, so it is expected behavior. Not sure if there is a clean way to do it
     
  3. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,026
    any dirty life hack?
     
  4. Discipol

    Discipol

    Joined:
    May 6, 2015
    Posts:
    83
    Use ScriptableObjects and have a reference for each individual pack.
     
  5. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,026