#2
bifujian1122019-08-29 16:32
|
程序代码:
using UnityEngine;
public class Graph : MonoBehaviour
{
public Transform pointPrefab;
public int resolution = 10;
private void Awake()
{
private int a ;//这句原文为字段
Vector3 scale = Vector3.one / 5f;
Vector3 position;
//position.y = 0f;
position.z = 0f;
for (int i = 0; i < 10; i++)
{
Transform point = Instantiate(pointPrefab);
//point.localPosition = Vector3.right * ((i + 0.5f) /5f -1f);
position.x = (i + 0.5f) / 5f - 1f;
position.y = position.x * position.x;
point.localPosition = position;
point.localScale = scale;
}
}
}
就比如position提示“不存在position”,请问其中的道理是什么?public class Graph : MonoBehaviour
{
public Transform pointPrefab;
public int resolution = 10;
private void Awake()
{
private int a ;//这句原文为字段
Vector3 scale = Vector3.one / 5f;
Vector3 position;
//position.y = 0f;
position.z = 0f;
for (int i = 0; i < 10; i++)
{
Transform point = Instantiate(pointPrefab);
//point.localPosition = Vector3.right * ((i + 0.5f) /5f -1f);
position.x = (i + 0.5f) / 5f - 1f;
position.y = position.x * position.x;
point.localPosition = position;
point.localScale = scale;
}
}
}
只有本站会员才能查看附件,请 登录
[此贴子已经被作者于2019-8-29 11:45编辑过]