Created
May 29, 2019 09:38
-
-
Save andybak/a0da4f5f6a6476db55c3fb6a80baadd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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