本文整理汇总了C#中UIComponent.GetComponentsInChildren方法的典型用法代码示例。如果您正苦于以下问题:C# UIComponent.GetComponentsInChildren方法的具体用法?C# UIComponent.GetComponentsInChildren怎么用?C# UIComponent.GetComponentsInChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIComponent
的用法示例。
在下文中一共展示了UIComponent.GetComponentsInChildren方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoToolTips
/// <summary>
/// Sets up tool tips. Would have been much easier if they would have let us specify the name of the components.
/// </summary>
/// <param name="component"></param>
/// <returns></returns>
private System.Collections.IEnumerator DoToolTips(UIComponent component)
{
yield return new WaitForSeconds(0.500f);
try
{
UICheckBox[] cb = component.GetComponentsInChildren<UICheckBox>(true);
// List<UIDropDown> dd = new List<UIDropDown>();
// component.GetComponentsInChildren<UIDropDown>(true, dd);
// if (dd.Count > 0)
// {
// dd[0].tooltip = "Sets the number of vehicles you want to reserve.\nStart small and work you way up, rarely will you ever need more than the 8-24 range.\n Option can be changed during game.";
// dd[0].selectedIndex = GetOptionIndexFromValue(config.VehicleReserveAmount);
// }
if (cb != null && cb.Length > 0)
{
for (int i = 0; i < (cb.Length); i++)
{
switch (cb[i].text)
{
case "Enable Verbose Logging":
cb[i].tooltip = "Enables detailed logging for debugging purposes\n See config file for even more options, unless there are problems you probably don't want to enable this.\n Option must be set before loading game.";
break;
case "Enable GUI (CTRL + L)":
cb[i].tooltip = "Enable the availability of the in game gui\n (very handy but technically not required)\n Option must be set before loading game.";
break;
case "Dump Stats to log on map exit":
cb[i].tooltip = "Enable this to have the map data stats writen to your log file upon each map unload.\n You may configure this to use a seperate file if you like by a setting in your config file.\n Option must be set before loading game.";
break;
case "Auto show on map load":
cb[i].tooltip = "Enable the info panel to be shown automatically on map load.\n Option must be set before loading game.";
break;
case "Use alternate keybinding":
cb[i].tooltip = "Enable the use of an alternative key to trigger the gui\n You can set this in your config file\n The default alternative is LeftControl + (LeftAlt + L)<-same time, if not changed.";
break;
default:
break;
}
}
}
if (Application.platform == RuntimePlatform.WindowsPlayer)
{
List<UIButton> bb = new List<UIButton>();
component.GetComponentsInChildren<UIButton>(true, bb);
if ( bb.Count > 0)
{ bb[0].tooltip = "On windows this will open the config file in notepad for you.\n *PLEASE CLOSE NOTEPAD* when you're done editing the conifg.\n If you don't and close the game steam will think CSL is still running till you do."; }
}
}
catch(Exception ex)
{
/* I don't really care.*/
Helper.dbgLog("", ex, true);
}
yield break;
}
示例2: DoToolTips
/// <summary>
/// Sets up tool tips. Would have been much easier if they would have let us specify the name of the components.
/// </summary>
/// <param name="component"></param>
/// <returns></returns>
private System.Collections.IEnumerator DoToolTips(UIComponent component)
{
yield return new WaitForSeconds(0.500f);
try
{
UICheckBox[] cb = component.GetComponentsInChildren<UICheckBox>(true);
List<UIDropDown> dd = new List<UIDropDown>();
component.GetComponentsInChildren<UIDropDown>(true, dd);
if (dd.Count > 0)
{
dd[0].tooltip = "Sets the number of vehicles you want to reserve.\nStart small and work you way up, rarely will you ever need more than the 8-24 range.\n Option can be changed during game.";
dd[0].selectedIndex = GetOptionIndexFromValue(config.VehicleReserveAmount);
}
if (cb != null && cb.Length > 0)
{
for (int i = 0; i < (cb.Length); i++)
{
switch (cb[i].text)
{
case "Enable Verbose Logging":
cb[i].tooltip = "Enables detailed logging for debugging purposes\n See config file for even more options, unless there are problems you probably don't want to enable this.\n Option must be set before loading game.";
break;
case "Enable CTRL+(S + V) GUI":
cb[i].tooltip = "Enable the availability of the in game gui\n (very handy but technically not required)\n Option must be set before loading game.";
break;
case "Dump Stats to log on map exit":
cb[i].tooltip = "Enable this to have the vehicle stats writen to your log file upon each map unload.\n You may configure this to use a seperate file if you like by a setting in your config file.\n Option must be set before loading game.";
break;
default:
cb[i].tooltip = cb[i].tabIndex.ToString() + " " + cb[i].name + " - " + cb[i].cachedName.ToString();
if (cb[i].text.Contains("GUI: Reset Stats every so often"))
{
cb[i].tooltip = string.Concat("Enabled this to periodically clear the vehicle statistics data.\n Option should* be set before loading game.\n",
"The frequency can be changed in your config file by the ResetStatsEveryXMin entry.\n *While you can change this during a game the effect may not be seen till toggling autorefresh.");
}
break;
}
}
}
if (Application.platform == RuntimePlatform.WindowsPlayer)
{
List<UIButton> bb = new List<UIButton>();
component.GetComponentsInChildren<UIButton>(true, bb);
if ( bb.Count > 0)
{ bb[0].tooltip = "On windows this will open the config file in notepad for you.\n *PLEASE CLOSE NOTEPAD* when you're done editing the conifg.\n If you don't and close the game steam will think CSL is still running till you do."; }
}
}
catch(Exception ex)
{
/* I don't really care.*/
Helper.dbgLog("", ex, true);
}
yield break;
}
示例3: DoToolTips
/// <summary>
/// Sets up tool tips. Would have been much easier if they would have let us specify the name of the components.
/// </summary>
/// <param name="component"></param>
/// <returns></returns>
private System.Collections.IEnumerator DoToolTips(UIComponent component)
{
yield return new WaitForSeconds(0.300f); //pause for 1/2 second then come back and do rest.
try
{
if (Mod.DEBUG_LOG_ON) { Helper.dbgLog("Refreshing tooltips telemetrylevel=" + Mod.config.TelemetryLevel.ToString()); }
UICheckBox[] cb = component.GetComponentsInChildren<UICheckBox>(true);
if (cb != null && cb.Length > 0)
{
for (int i = 0; i < (cb.Length); i++)
{
switch (cb[i].text)
{
case "Enable Verbose Logging":
cb[i].tooltip = "Enables detailed logging for debugging purposes\n See config file for even more options, unless there are problems you probably don't want to enable this.";
break;
//case "Disable OnAppStartup":
// cb[i].tooltip = "Disables telemetry sent for when you boot up the game exe.\n**Please Note: This setting does nothing atm, mods load too late to change this\n if you want to disable this you must use patched Assemembly-CSharp.dll";
// cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableOnAppStart);
// break;
//case "Disable Machine Info":
// cb[i].tooltip = "Disables telemetry sent for when you boot up the game exe.\n it includes information to id your specific computer spec & steamid or paradox login\n**Please Note: This setting does nothing atm, mods load too late to change this\n if you want to disable this you must use patched Assemembly-CSharp.dll";
// cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableMachineInfo);
// break;
case "Disable Custom Content":
cb[i].tooltip = "Disables telemetry about what custom content you load with a map.\n It includes information such has counts of building,props,trees,vehicles,mods, and details about every enabled mod.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableCustomContent );
break;
case "Disable Session Start":
cb[i].tooltip = "Disables telemetry about what Session Starts(loading a map).\n it includes information such has mapname,mapfilename,loadmode,environment,inverted traffic and map guid.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableStartSession);
break;
case "Disable Session Loaded":
cb[i].tooltip = "Disables telemetry about a Loaded Session (map loading completed).\n it includes information such has current time, time in your map, and how long part of the load took to execute.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableSessionLoaded );
break;
case "Disable Session End":
cb[i].tooltip = "Disables telemetry about a Session End (map unloaded).\n it includes data that a session has ended, and of what type it was (map,game,asset).";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableEndSession);
break;
case "Disable Exception Reporting":
cb[i].tooltip = "Disables telemetry about an Exception Error occuring.\n This only sends the 'type' of error and the basic error message, it does not send a stack trace.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableExceptionReporting);
break;
case "Disable OnAppQuit":
cb[i].tooltip = "Disables telemetry sent when you exit the game.\n This includes data that you exited the game and a timestamp.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableOnQuit);
break;
case "Disable Store Clicks":
cb[i].tooltip = "Disables telemetry sent when you click on a store item.\n This only sends that you clicked on the store button.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableOnStoreClick);
break;
case "Disable Feed Clicks":
cb[i].tooltip = "Disables telemetry sent when you click on a workshop feed\\news item \n This sends that you clicked on one and the target steamAppID or url upon which you clicked.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableOnClicks);
break;
case "Disable Paradox Login":
cb[i].tooltip = "Disables telemetry sent when the game logs you into your paradox account \n This sends data that you were auto-logged in and a timestamp.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableParadoxLogin);
break;
case "Enable All SendToFile Only":
cb[i].tooltip = "Enables all telemetry - but nothing will be sent to Paradox, only logged in your log file.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.EnableAllButLogToFileInstead);
break;
case "DisableWorkshopAdPanel":
cb[i].tooltip = "Disables the workshop 'feed' panel, does NOT disable Workshop in general.\n There is no telemetry directly associated with disabling this.\n I simply find the feeds a waste of bandwidth.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableWorkshopAdPanel);
break;
case "NoOpThePush":
cb[i].tooltip = "This is a master overide to make Telemetry.Push() (function that sends the data) do absolutely nothing.\n If set nothing will be sent OR even logged (if not in verbose logging mode).";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.NoOpThePush);
break;
case "SetURL To LocalHost":
cb[i].tooltip = "Sets the Paradox API URL to whatever you have in your config file.\n The default is 'https://localhost:49100/cities' if enabled.\n Can be used if you want to enable everything but send data your own web server.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.SetAPIUrlLocalHost);
break;
case "Disable All Telemetry":
cb[i].tooltip = "Disables all telemetry - Nothing will be sent to Paradox.\nYou do NOT have to select the individual options if this is set.\n *Please see note at bottom of options page about the OnAppStartup and MachineInfo telemetry events.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableAll);
break;
case "Enable All Telemetry":
cb[i].tooltip = "Enables all telemetry - The game's default behavior.";
cb[i].isChecked = Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.EnableAll);
break;
default:
break;
}
}
}
List<UIButton> bb = new List<UIButton>();
component.GetComponentsInChildren<UIButton>(true, bb);
if ( bb.Count > 0)
//.........这里部分代码省略.........
示例4: DoToolTips
/// <summary>
/// Sets up tool tips. Would have been much easier if they would have let us specify the name of the components.
/// </summary>
/// <param name="component"></param>
/// <returns></returns>
private System.Collections.IEnumerator DoToolTips(UIComponent component)
{
yield return new WaitForSeconds(0.500f);
try
{
UICheckBox[] cb = component.GetComponentsInChildren<UICheckBox>(true);
if (cb != null && cb.Length > 0)
{
for (int i = 0; i < (cb.Length); i++)
{
switch (cb[i].text)
{
case "Enable Verbose Logging":
cb[i].tooltip = "Enables detailed logging for debugging purposes\n See config file for even more options, unless there are problems you probably don't want to enable this.\n Option must be set before loading game.";
break;
case "Auto show on map load":
cb[i].tooltip = "Enable the info panel to be shown automatically on map load.";
break;
case "Use alternate key-bindings":
cb[i].tooltip = "Enable the alternate keybinding to show the panel\n Default alternate is left-control + left-alt + P\n You may set a custom binding in your config file if you like.";
break;
default:
break;
}
}
}
if (Application.platform == RuntimePlatform.WindowsPlayer)
{
List<UIButton> bb = new List<UIButton>();
component.GetComponentsInChildren<UIButton>(true, bb);
if ( bb.Count > 0)
{ bb[0].tooltip = "On windows this will open the config file in notepad for you.\n *PLEASE CLOSE NOTEPAD* when you're done editing the conifg.\n If you don't and close the game steam will think CSL is still running till you do."; }
}
}
catch(Exception ex)
{
/* I don't really care.*/
Helper.dbgLog("", ex, true);
}
yield break;
}
示例5: DoToolTips
/// <summary>
/// Sets up tool tips. Would have been much easier
/// if they would have let us specify the name of the components during creation but they don't.
/// we've gotta loop though them looking for matches.
/// We could of course just like created our own but that's more work and overkill for what we're doing.
/// </summary>
/// <param name="component">The UIComponent ref we need to work on</param>
/// <returns></returns>
private System.Collections.IEnumerator DoToolTips(UIComponent component)
{
//pause for 1/2 second then come back and do rest.
//we do this to avoid some flakyness with the gui if we do it without waiting like 10ms
yield return new WaitForSeconds(0.300f);
try
{
if (Mod.DEBUG_LOG_ON) { Helper.dbgLog("Refreshing tooltips."); }
UICheckBox[] cb = component.GetComponentsInChildren<UICheckBox>(true);
if (cb != null && cb.Length > 0)
{
for (int i = 0; i < (cb.Length); i++)
{
switch (cb[i].text)
{
case "Enable debug logging.":
cb[i].tooltip = "Enables detailed logging for debugging purposes\n See config file for even more options, unless there are problems you probably don't want to enable this.";
break;
case "Change trees on map load.":
cb[i].tooltip = "If enabled the mod will modify existing trees on any map you load. \n You may not see actual changes till the map is saved and reloaded.\n If disabled the mod will not touch trees";
break;
case "Update existing trees on map load.":
cb[i].tooltip = "If enabled the mod will update the already created tress to remove dirt\n while the map loads so you can see changes.\n *Please note this can add additional time, about\n 10-13seconds per 100k created trees*";
break;
case "Change props on map load.":
cb[i].tooltip = "This option doesn't do anything... yet";
break;
default:
break;
}
}
}
}
catch (Exception ex)
{
Helper.dbgLog("", ex, true);
}
yield break; //bust out of the co-routine never to return.
}
示例6: Do_ToolTips
/// <summary>
/// Sets up tool tips. Would have been much easier if they would have let us specify the name of the 'components'.
/// or if C\O just let use set the tooltips directly during creation, but they don't so we work around it.
/// </summary>
/// <param name="component">The UIComponent that we'll operate on</param>
/// <returns>nothing really it's an enumerator</returns>
private System.Collections.IEnumerator Do_ToolTips(UIComponent component)
{
// So remember above when we talked about coroutines, well this one.
// We're not doing anything fancy like trying to return to ourselves on every game frame.
// instead we have a very simple one that just wait's 1/2 a second, does some work and then dies
// and does not stick around.
yield return new WaitForSeconds(0.500f); //Go wait for 1/2 a second and do other things you need to do.
try //ok 1/2 a second has passed and it's come back to us, let's do some stuff.
{
//create an array of UICheckBox's call cb and fill it with all the checkboxes inside the 'component' we were fed in.
UICheckBox[] cb = component.GetComponentsInChildren<UICheckBox>(true);
// let's make sure our array of checkboxes actually got filled with some data.
if (cb != null && cb.Length > 0)
{
// Awesome it has some checkboxes, now for every single one let's go compare the text
// it it matches certain text, then lets set the correct tool tip text on that one.
// The reason why we have to loop though all of them is because Colosal doesn't
// set the object's .name property to what we actually called it and there is no other way
// that I know of to pick out the right one directly, so we have to loop though them one at a time.
// annoying but not a big deal, I mean how many are you actually creating anyway right?
for (int i = 0; i < (cb.Length); i++)
{
// I use a switch here as a better example for when you might have 1/2 a dozen or more
// technically since I only have three here a couple of if(){} statments would have worked just the same.
switch (cb[i].text)
{
case "Enable Verbose Logging":
cb[i].tooltip = "Enables detailed logging for debugging purposes\n See config file for even more options, unless there are problems you probably don't want to enable this.";
break;
case "Use Alternate Keybinding":
cb[i].tooltip = "Enable the use of an alternative key to trigger the gui\n You can set this in your config file\n The default alternative is LeftControl + (LeftAlt + V)<-same time, if not changed.";
break;
case "Auto Show On Map Load":
cb[i].tooltip = "Sets if the info panel will show automatically when your maps load.";
break;
default:
//Well if it's not what we're looking for do anything
break;
}
}
}
List<UIButton> bb = new List<UIButton>(); //create a new list of UIButtons.
component.GetComponentsInChildren<UIButton>(true, bb); //Get get all child buttons and stick them in our list
//do we at least have 1 child, if we do it must be out button cause we only created one!
if ( bb.Count > 0)
{
//Good we have 1, now since this is a UIButton object it has a tooltip setting, let's set it.
bb[0].tooltip = "Clicking on this will save your settings to your config file.";
}
}
catch(Exception ex)
{
Logger.dbgLog("Some error happened.", ex, true);
}
yield break; //break out of our coroutine, permenantly.
}