there is no build fail but editor script doesn't work in build

using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif

    public class sitrup : MonoBehaviour {

     
      
        void Start ()
        {
           
#if UNITY_EDITOR
            
            Selection.activeObject = gameObject;
#endif

        }
        
    }
}

Hi,

Because the brakcets " #if UNITY_EDITOR / #endif" only read code when you are inside the editor.
This is why it doesn’t work elsewhere (like standalone)

Use : UNITY_STANDALONE_WIN , or don’t use anything if you wanna execute the code in standalone.
Also, you can refer to : Unity - Manual: Conditional Compilation
:wink: