using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; using UnityEngine.UI; namespace BuildSystem { public class PlaceSwitch : MonoBehaviour { public Button btn; public GameObject flag; public GameObject placePanel; bool state = false; private void Awake() { btn.onClick.AddListener(() => { state = !state; if (state) { BuildSystemManager.Instance.isCanPlace = true; flag.SetActive(true); placePanel.SetActive(true); btn.transform.DOLocalMoveX(50, 0.2f); } else { if (BuildSystemManager.Instance.placeObj) { Destroy(BuildSystemManager.Instance.placeObj.gameObject); } BuildSystemManager.Instance.isCanPlace = false; flag.SetActive(false); placePanel.SetActive(false); btn.transform.DOLocalMoveX(-50, 0.2f); } }); } } }