因此,我一直在关注Youtube上关于围栏搭建的教程,我已经做了所有的事情。唯一的问题是它现在不能工作了,两个函数说我的一个变量指针没有定义它们,尽管在教程中它是工作的,这是我的脚本
using System.Collections;
using System;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
public class CreateFence : MonoBehaviour
{
public int Building = 1;
bool creating;
ShowMousePosition Pointer;
public GameObject polePrefab;
public GameObject fencePrefab;
// Start is called before the first frame update
void Start()
{
Pointer = GetComponent<ShowMousePosition>();
}
// Update is called once per frame
void Update()
{
}
void getInput()
{
if(Input.GetMouseButtonDown(0) && Building == 1)
{
startFence();
}
else if (Input.GetMouseButtonUp(0))
{
setFence();
}
else if (creating)
{
updateFence();
}
}
void startFence()
{
creating = true;
Vector3 startpos = System.Reflection.Pointer.getWorldPoint();///getWorldPoint says Pointer has no definition for it
startpos = System.Reflection.Pointer.snapPosition(startpos);///snapPosition says Pointer has no definition for it
}
void setFence()
{
creating = false;
}
void updateFence()
{
}
}发布于 2020-05-15 02:10:36
所以我弄清楚了,这是系统反映的问题,显然unity自动纠正了我的错误,Apple = Microsoft Visual Studios
https://stackoverflow.com/questions/61801218
复制相似问题