You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
44 lines
1.2 KiB
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);
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|