Skip to content

Instantly share code, notes, and snippets.

@suakig
Last active August 29, 2015 14:19
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 suakig/3d5d18e406320d4cdb65 to your computer and use it in GitHub Desktop.
Save suakig/3d5d18e406320d4cdb65 to your computer and use it in GitHub Desktop.
Mask.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Mask : MonoBehaviour {
private const string PATH = "Prehabs/Color/";
public enum ID
{
Red = 1,
Blue = 2,
Green = 4,
Black = 8,
White = 16,
}
public class Sample
{
public const string Red = "Red";
public const string Blue = "Blue";
public const string Green = "Green";
public const string Black = "Black";
public const string White = "White";
}
public ID id;
void Start()
{
string[] test = sample (id);
foreach (string str in test) {
Debug.Log (str);
GameObject child = Instantiate (Resources.Load (str)) as GameObject;
child.transform.parent = transform;
}
}
public string[] sample(ID id)
{
List<string> text = new List<string> ();
if ( (id & ID.Red) == ID.Red) {
text.Add (PATH + Sample.Red);
}
if ( (id & ID.Blue) == ID.Blue) {
text.Add (PATH + Sample.Blue);
}
if ( (id & ID.Green) == ID.Green) {
text.Add (PATH + Sample.Green);
}
if ( (id & ID.Black) == ID.Black) {
text.Add (PATH + Sample.Black);
}
if ( (id & ID.White) == ID.White) {
text.Add (PATH + Sample.White);
}
return text.ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment