コード例 #1
0
            public void MakeValid(Transform root, int index, Mesh mesh, Material material, MaterialPropertyBlock block)
            {
                obj.transform.SetParent(root);
                obj.transform.SetSiblingIndex(index);
                obj.SetActive(true);

                obj.transform.localPosition = Vector3.zero;
                obj.transform.localRotation = Quaternion.identity;
                obj.transform.localScale    = Vector3.one;

                if (filter == null)
                {
                    filter = InternalUtility.AddComponent <MeshFilter>(obj);
                }
                filter.sharedMesh = mesh;

                if (renderer == null)
                {
                    renderer = InternalUtility.AddComponent <MeshRenderer>(obj);
                }
                renderer.enabled        = true;
                renderer.sharedMaterial = material;
                renderer.SetPropertyBlock(block);
            }