Question by
ZerukStudios · Mar 06, 2020 at 06:52 AM ·
editorbuildunityeditorselectioneditor scripting
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
}
}
}
Comment
Answer by Scorpionzz · Mar 06, 2020 at 10:04 AM
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 : https://docs.unity3d.com/Manual/PlatformDependentCompilation.html ;)
Your answer
Follow this Question
Related Questions
How to change the project's Splash Image in a build? 0 Answers
Camera Editor,Camera Editor 1 Answer
Editor tool for selecting inverse dependencies, no-longer works in Unity 5.4? 1 Answer
Why does my shoot script break when I build the game 0 Answers
il2cpp.exe error pls help me and solve out my problem 1 Answer