Skip to content

Instantly share code, notes, and snippets.

@arknano
Created January 16, 2017 15:59
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 arknano/f7992178d25dc1f6e167b8ff1a9667a2 to your computer and use it in GitHub Desktop.
Save arknano/f7992178d25dc1f6e167b8ff1a9667a2 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PicaVoxel;
public class SetVolumeAlpha : MonoBehaviour {
public int alpha = 0;
//Sets the alpha on all voxels in the volume this script is placed on.
public void SetAlpha () {
var frame = GetComponent<Volume>().Frames[0];
for (int i = 0; i < frame.Voxels.Length; i++)
{
var c = frame.Voxels[i].Color; // get the current voxel colour
c.a = (byte)alpha ; // set the alpha
frame.Voxels[i].Color = c; // set the colour back
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment