using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using UnityEngine;
using UnityEngine.UI;
using Timer = System.Threading.Timer;
public class ObjectFinder : MonoBehaviour
{
public GameObject Player;//被传送的玩家
public GameObject FiledUI;
public InputField Filed;
public GameObject[] TargetOBJ;
private bool Is_Open;//是否已经打开了搜索器
private void Update()
{
if (Input.GetKey(KeyCode.LeftControl)&& Input.GetKeyDown(KeyCode.F))
{
FiledUI.SetActive(true);
Is_Open = true;
Timer timer = new Timer(delegate(object state)
{
FiledUI.SetActive(false);
Is_Open = false;
},null,6000,0);
}
if (Input.GetKeyDown(KeyCode.KeypadEnter)|| Input.GetKeyDown(KeyCode.Return)&& Is_Open)
{
FiledUI.SetActive(false);
foreach (var VARIABLE in TargetOBJ)
{
if (VARIABLE.name.Contains(Filed.text))
{
Player.GetComponent<Transform>().position = VARIABLE.GetComponent<Transform>().position;
break;
}
}
}
}
}
自用工具 Unity 在游戏内搜索物体传送工具
猜你喜欢
转载自blog.csdn.net/qq_58804985/article/details/126666932
今日推荐
周排行