Skip to content

Instantly share code, notes, and snippets.

@andybak
Created May 29, 2019 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andybak/a0da4f5f6a6476db55c3fb6a80baadd7 to your computer and use it in GitHub Desktop.
Save andybak/a0da4f5f6a6476db55c3fb6a80baadd7 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
[ExecuteInEditMode]
public class ConvertToPoints : MonoBehaviour
{
void Start()
{
var mf = GetComponent<MeshFilter>();
var mesh = Application.isPlaying ? mf.mesh : mf.sharedMesh;
mesh.SetIndices(Enumerable.Range(0, mesh.vertices.Length).ToArray(), MeshTopology.Points, 0);
if (Application.isPlaying) gameObject.GetComponent<MeshFilter>().mesh = mesh;
else gameObject.GetComponent<MeshFilter>().sharedMesh = mesh;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment