Use Enum Property
In the bom2 project, you must have a separate script to control mode switching. Other scarima determines which Enum to switch to based on this mode to enable some functions in this mode. At the beginning, I used the Inspector method to control the enum selected value in the enum script, and then created a public variable in the script to be judged to adapt to the enum value changes. Later I changed to using the enum method of the class.
// Modeselector. CS Using Unityengine; Using System. collections; Public Enum Modeenum {assemblyview, tearview, profileview, lateral view} Public Class Modeselector: monobehaviour { Private Static Int Myvar; Public Static Modeenum modeenumproperty { Get { Return (Modeenum) myvar ;} Set {Myvar = ( Int ) Value ;}} // Use this for initialization Void Start () {modeenumproperty = Modeenum. assemblyview ;} // Update is called once per frame Void Update (){} Void Ongui (){ If (GUI. Button ( New Rect (screen. width/2 - 150 , 50 , 100 , 20 ), " Tear apart " ) {Modeenumproperty = Modeenum. tearview ;} If (GUI. Button ( New Rect (screen. width/ 2 +50 , 50 , 100 , 20 ), " 3D viewer " ) {Modeenumproperty = Modeenum. assemblyview ;}}}
//Navigationcontrol. CSOngui (){...If(Modeselector. modeenumproperty =Modeenum. assemblyview ){//Something to do}...}