31 lines
		
	
	
		
			686 B
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			31 lines
		
	
	
		
			686 B
		
	
	
	
		
			C#
		
	
	
	
|  | using System.Collections; | |||
|  | using System.Collections.Generic; | |||
|  | using UnityEngine; | |||
|  | 
 | |||
|  | public class ObjectSwitch : MonoBehaviour | |||
|  | { | |||
|  |     [SerializeField] GameObject mGobOn; | |||
|  |     [SerializeField] GameObject mGobOff; | |||
|  |     [SerializeField] Transform mTsfExplode; | |||
|  |     [SerializeField] GameObject mFxOff; | |||
|  | 
 | |||
|  |     private bool mIsOn = false; | |||
|  |     public bool IsOn | |||
|  |     { | |||
|  |         get | |||
|  |         { | |||
|  |             return mIsOn; | |||
|  |         } | |||
|  |         set | |||
|  |         { | |||
|  |             mIsOn = value; | |||
|  |             mGobOn.SetActive(mIsOn); | |||
|  |             mGobOff.SetActive(!mIsOn); | |||
|  | 
 | |||
|  |             if (!mIsOn) | |||
|  |             { | |||
|  |                 Instantiate(mFxOff, mTsfExplode.position, mTsfExplode.rotation); | |||
|  |             } | |||
|  |         } | |||
|  |     } | |||
|  | } |