相关疑难解决方法(0)

无法销毁错误的 Transform 组件

我有一些 Unity 代码,可以使用 ac# 脚本创建一个预制件的网格(总共 2^ 维)。更改“尺寸”值后(现在通过编辑器),我希望在 Unity 使用 OnValidate 更新之前删除所有预制件。Unity 似乎不想删除之前代表空间的一组对象,因为这些对象仍然可以在 Unity Hierarchy Pane 中访问:

无法统一销毁对象。错误说:

“无法销毁'XXX'的Transform组件。如果您想销毁游戏对象,请改为在游戏对象上调用'Destroy'。不允许销毁transform组件。”

(参考函数 DeletePoints/GeneratePoints。调用图: OnValidate --> GeneratePoints(->DeletePoints, ->GeneratePointsHelper)

using UnityEngine;
using System;
using System.Collections.Generic;
using System.Collections;

public class BinarySpacePointGenerator : MonoBehaviour {
    private const int UNITY_DRAW_SPACE_DIMENSIONALITY = 3;
    /**
     * These values denote spacings for the three dimensional space between binary points.
     */
    public float xoff, yoff, zoff;
    public float scale;
    public Transform pointPrefab;
    /**
     *  The current dimensionality of binary space to be …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine unity5

1
推荐指数
1
解决办法
6584
查看次数

标签 统计

c# ×1

unity-game-engine ×1

unity5 ×1