Skip to content

Instantly share code, notes, and snippets.

@GarethIW
Last active February 22, 2017 08:57
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 GarethIW/6e2b6f9e31c20721653d425d9e65ec28 to your computer and use it in GitHub Desktop.
Save GarethIW/6e2b6f9e31c20721653d425d9e65ec28 to your computer and use it in GitHub Desktop.
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