Last active
August 29, 2015 14:19
-
-
Save suakig/3d5d18e406320d4cdb65 to your computer and use it in GitHub Desktop.
Mask.cs
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 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