public void createLists() { musicgroup = new ToggleGroups <Music>(false); foreach (Music music in staticstuff.loadedmusics) { GameObject newtoggle = Instantiate(sampleMusicToggle) as GameObject; MusicSelectionToggle musictoggle = newtoggle.GetComponent <MusicSelectionToggle> (); musictoggle.textbox.text = music.name; musictoggle.music = music; musictoggle.toggle.onValueChanged.AddListener(delegate { onMusicClick(musictoggle); }); newtoggle.transform.SetParent(musicContentPanel); } spritegroup = new ToggleGroups <PlayerTexture> (false); foreach (PlayerTexture text in staticstuff.loadedsprites) { GameObject newtoggle = Instantiate(sampleSpriteToggle) as GameObject; SpriteSelectionToggle spritetoggle = newtoggle.GetComponent <SpriteSelectionToggle> (); spritetoggle.sprite_name.text = text.config.name; spritetoggle.sprite = text; spritetoggle.toggle.onValueChanged.AddListener(delegate { onSpriteClick(spritetoggle); }); newtoggle.transform.SetParent(spriteContentPanel); } scriptgroup = new ToggleGroups <PlayerScripts> (true); foreach (PlayerScripts script in staticstuff.loadedScripts) { GameObject newtoggle = Instantiate(sampleScriptToggle) as GameObject; ScriptSelectionToggle scripttoggle = newtoggle.GetComponent <ScriptSelectionToggle> (); scripttoggle.script_name.text = script.name; scripttoggle.script = script; scripttoggle.toggle.onValueChanged.AddListener(delegate { onScriptClick(scripttoggle); }); newtoggle.transform.SetParent(scriptContentPanel); } }
void onSpriteClick(SpriteSelectionToggle clickedtoggle) { if (clickedtoggle.toggle.isOn) { spritegroup.add(clickedtoggle.toggle, clickedtoggle.sprite); } else { spritegroup.remove(clickedtoggle.toggle, clickedtoggle.sprite); } }