50 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.EventSystems;
 | |
| using MyFrameworkPure;
 | |
| using CommonScript;
 | |
| public class door_control : MonoBehaviour
 | |
| {
 | |
|     [SerializeField] private MouseButton mouseButton = MouseButton.Left;
 | |
|     public bool 启用交互 = false;
 | |
|     public bool 是否开门 = false;
 | |
|     public GameObject 验电笔;
 | |
|     public string 开门动画;
 | |
|     public string 关门动画;
 | |
|     public Animator animator;
 | |
|     // Start is called before the first frame update
 | |
|     void Start()
 | |
|     {
 | |
|         //EventTriggerListener.Get(transform.gameObject).onClick_Data += Onclick;
 | |
|     }
 | |
|     private void OnMouseDown()
 | |
|     {
 | |
|         if (this.enabled)
 | |
|         {
 | |
|             if (!EventSystem.current.IsPointerOverGameObject())
 | |
|             {
 | |
|                 // 是否开门 = !是否开门;
 | |
|                 if (启用交互 == true)
 | |
|                 {//sssssssss
 | |
|                     是否开门 = !是否开门;
 | |
|                     if (是否开门 == true)
 | |
|                     {
 | |
|                         //是否开门 = false;
 | |
|                         animator.Play(开门动画);
 | |
|                         //是否开门 = false;
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         //是否开门 = true;
 | |
|                         animator.Play(关门动画);
 | |
|                         //是否开门 = true;
 | |
| 
 | |
| 
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |