从代码

时间:2016-10-22 16:28:07

标签: unity3d

是否可以将父游戏对象放入UnityEditor并从代码中查看子游戏对象?我尝试创建具有必要结构的自定义类,但是坚持团结并不理解它。

public Path Path1;
public Path Path2;
public Path Path3;
public Path Path4;

enter image description here

[Serializable]
public class Path : MonoBehaviour
{
    public List<Way> Ways;

    public Path ()
    {
    }
}

方式课

[Serializable]
public class Way : MonoBehaviour
{
    public Transform StartPoint { get; set;}
    public Transform[] EndPoints { get; set;}
    public Transform[] AngleWaypoints { get; set;}

    public Way ()
    {
    }
    public Way (Transform startPoint, Transform[] endPoints, Transform[] angleWaypoints)
    {
        this.StartPoint = startPoint;
        this.EndPoints = endPoints;
        this.AngleWaypoints = angleWaypoints;
    }


}

1 个答案:

答案 0 :(得分:0)

你的班级需要从MonoBehaviour继承,也许是你失踪的。

应该看起来像

 class myClass : MonoBehaviour{
 }

您已选择GameManager脚本。尝试选择Path_1,Path类的所有公共变量都应出现在UnityEditor中。

此外,您可以将UnityEditor模式更改为Debug,这将显示更多信息UnityEditor Debug Mode