Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class DrawWireframes : MonoBehaviour {
  6.     public bool childrenArePlanes = true;
  7.     public bool childrenAreCubes = false;
  8.     public bool justSelf = false;
  9.     public Color selfColor;
  10.     void Start () {
  11.         Mesh _mesh;
  12.         MeshFilter[] mfs = GetComponentsInChildren<MeshFilter>();
  13.  
  14.         if (justSelf) {
  15.             _mesh = GetComponent<MeshFilter>().mesh;
  16.             if (childrenAreCubes) {
  17.                 _mesh.SetIndices(new int[] {0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,6,1,7,3,5,2,4} ,MeshTopology.Lines,0);
  18.             }
  19.         } else {
  20.             foreach (MeshFilter mf in mfs) {
  21.                 _mesh = mf.mesh;
  22.  
  23.                 if (childrenArePlanes) {
  24.                     _mesh.SetIndices(new int[] {0,1,2,3,0},MeshTopology.LineStrip,0);
  25.                 } else if (childrenAreCubes) {
  26.                     _mesh.SetIndices(new int[] {0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,6,1,7,3,5,2,4} ,MeshTopology.Lines,0);
  27.                 }
  28.             }
  29.         }
  30.     }
  31.  
  32.     void Update() {
  33.         if (justSelf) {
  34.             MeshRenderer mr = GetComponent<MeshRenderer>();
  35.             mr.material.color = selfColor;
  36.         }
  37.     }
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement