mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Fix C# code sample in Optimization using MultiMeshes
Thanks to @Dr-Primary for providing a fix :) This closes #3659.
This commit is contained in:
@@ -76,25 +76,25 @@ efficient for millions of objects, but for a few thousands, GDScript should be f
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public class MultiMeshInstance : Godot.MultiMeshInstance
|
||||
public class YourClassName : MultiMeshInstance
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
// Create the multimesh.
|
||||
var multimesh = new MultiMesh();
|
||||
Multimesh = new MultiMesh();
|
||||
// Set the format first.
|
||||
multimesh.TransformFormat = MultiMesh.TransformFormatEnum.Transform3d;
|
||||
multimesh.ColorFormat = MultiMesh.ColorFormatEnum.None;
|
||||
multimesh.CustomDataFormat = MultiMesh.CustomDataFormatEnum.None;
|
||||
Multimesh.TransformFormat = MultiMesh.TransformFormatEnum.Transform3d;
|
||||
Multimesh.ColorFormat = MultiMesh.ColorFormatEnum.None;
|
||||
Multimesh.CustomDataFormat = MultiMesh.CustomDataFormatEnum.None;
|
||||
// Then resize (otherwise, changing the format is not allowed)
|
||||
multimesh.InstanceCount = 1000;
|
||||
Multimesh.InstanceCount = 1000;
|
||||
// Maybe not all of them should be visible at first.
|
||||
multimesh.VisibleInstanceCount = 1000;
|
||||
Multimesh.VisibleInstanceCount = 1000;
|
||||
|
||||
// Set the transform of the instances.
|
||||
for (int i = 0; i < multimesh.VisibleInstanceCount; i++)
|
||||
for (int i = 0; i < Multimesh.VisibleInstanceCount; i++)
|
||||
{
|
||||
multimesh.SetInstanceTransform(i, new Transform(Basis.Identity, new Vector3(i * 20, 0, 0)));
|
||||
Multimesh.SetInstanceTransform(i, new Transform(Basis.Identity, new Vector3(i * 20, 0, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user