-
-
Save GarethIW/6e2b6f9e31c20721653d425d9e65ec28 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 UnityEngine; | |
using PicaVoxel; | |
public class GetPalette : MonoBehaviour | |
{ | |
void Start () | |
{ | |
// Initialise a list of colours to hold our palette | |
List<Color> palette = new List<Color>(); | |
// Get a reference to the voxel array | |
var voxels = GetComponent<Volume>().Frames[0].Voxels; | |
for (int i = 0; i < voxels.Length; i++) | |
// Only include the colour of active voxels, and check we haven't already added it | |
if (voxels[i].State != VoxelState.Inactive && !palette.Contains(voxels[i].Color)) | |
palette.Add(voxels[i].Color); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment