public static string Execute(string[] tokens) { // incorrect number of tokens found if (tokens.Length != 1) { return("[Error] You must provide a valid path to the game object to query."); } // attempt to find the object GameObject foundObject = CommandHelpers.GetGameObject(tokens[0]); // object not found? if (foundObject == null) { return("[Error] Could not find the specified game object. Check the path. Paths must be case sensitive."); } Dictionary <string, Component> componentMapping = CommandHelpers.GetComponentMapping(foundObject); List <string> componentNames = componentMapping.Keys.ToList(); // find the longest component name int longestComponentName = 0; foreach (string componentName in componentNames) { longestComponentName = Mathf.Max(componentName.Length, longestComponentName); } // build the list of components string result = "Found the following components: "; foreach (string componentName in componentNames) { Component component = componentMapping[componentName]; string status = component is Behaviour ? ((component as Behaviour).enabled ? "Enabled" : "Disabled") : "Always Enabled"; result += System.Environment.NewLine + " " + componentName.PadRight(longestComponentName) + " : " + status; } return(result); }