Exemplo n.º 1
0
        void CreateMesh()
        {
            mesh = generator.MakeRock();

            previewMeshFilter.mesh = Convert.ToUnityMesh(mesh);

            if (previewEditor)
            {
                DestroyImmediate(previewEditor);
            }

            previewEditor = Editor.CreateEditor(previewObj);
        }
Exemplo n.º 2
0
        Mesh CreateRandomRock()
        {
            // Copy existing settings
            var settings = new RockGenerationSettings(generator.Settings);

            // Modify rock shape
            UnityEngine.Matrix4x4 rockTransform = UnityEngine.Matrix4x4.TRS(
                new Vector3(2, 2, 2),
                Random.rotation,
                new Vector3(Random.Range(.5f, 1.5f),
                            Random.Range(.5f, 1.5f),
                            Random.Range(.5f, 1.5f))
                );
            settings.Transform = Convert.FromUnityMatrix(rockTransform);

            // Apply settings. Generator will optimize generation base on which settings was changed.
            generator.Settings = settings;

            // Generator do not use Unity's types, so it can be used outside of Unity
            // Notable different are: Matrix4x4, Mesh
            return(Convert.ToUnityMesh(generator.MakeRock()));
        }
Exemplo n.º 3
0
 internal void UpdateMesh()
 {
     FrameTime.Instance.StartWork("Gen");
     meshFilter.mesh = Convert.ToUnityMesh(generator.MakeRock());
     FrameTime.Instance.EndWork("Gen");
 }