DeveloperConsole.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
	void Update ()
	{
		if ( transitionTime < 0f ) transitionTime = 0f;
		
		// Update display pos
		if ( showing )
		{
			if ( displayAmount < 1f )
			{
				displayAmount = Mathf.Clamp01( displayAmount + Time.deltaTime / transitionTime );
			}
		}
		else
		{
			if ( displayAmount > 0f )
			{
				displayAmount = Mathf.Clamp01( displayAmount - Time.deltaTime / transitionTime );
			}
		}
		if (!showing && displayAmount == 0f && Input.GetKeyUp(toggleKeyCode))
		{
			cursorShowingBefore = Screen.showCursor;
			cursorLockedBefore = Screen.lockCursor;
			showing = !showing;
			if (showing) focusOnTextField = true;
			
			if (showCursorWhenActive)
			{
				Screen.showCursor = true;
				Screen.lockCursor = false;
			}
		}
		
		if (showing)
		{
			if (showCursorWhenActive)
			{
				Screen.showCursor = true;
				Screen.lockCursor = false;
			}
		}
		
		if (timeUntilAutocompleteSelectionChangeAllowed > 0f)
		{
			timeUntilAutocompleteSelectionChangeAllowed -= 0.01f;
		}
		
		// Autocomplete
		if ( previousConsoleText != consoleText && !closeAutocomplete )
		{
			showingAutocomplete = false;
			
			foundGameObjectNames.Clear();
			foundComponentNames.Clear();
			foundMethodNames.Clear();
			foundFieldNames.Clear();
			foundPropertyNames.Clear();
			//foundGameObjectTags.Clear();
			
			string workWithText = consoleText;
			
			if ( workWithText.ToLower().StartsWith( "print " ) )
			{
				workWithText = workWithText.Substring( 6, workWithText.Length - 6 );
			}
			
			string[] splitDots = workWithText.Split( '.' );
			
			//if ( workWithText.StartsWith( "call " ) )
			//{
			//    callingFunction = true;
			
			//    splitDots = workWithText.Substring( 5, workWithText.Length - 5 ).Split( '.' );
			//}
			
			GameObject go = null;
			List<GameObject> gol = new List<GameObject>();
			
			if ( splitDots.Length == 1 )
			{
				if (!onlyAcceptAliases)
				{
					foundGameObjectNames.AddRange(gameObjectNames.FindAll(
						delegate(string goName)
						{
						return goName.ToLower().StartsWith(splitDots[0].ToLower());
					}
					));
					
					foundGameObjectNames.AddRange(tagList.FindAll(
						delegate(string goTag)
						{
						return goTag.ToLower().StartsWith(splitDots[0].ToLower());
					}
					));
				}
				foreach ( string key in dictionaryOfAliases.Keys )
				{
					if ( key.ToLower().StartsWith( splitDots[0].ToLower() ) )
						foundGameObjectNames.Add( key );
				}
			}
			if ( splitDots.Length == 2 )
			{
				if (!onlyAcceptAliases)
				{
					go = GameObject.Find(splitDots[0]);
					
					if (go != null)
					{
						Component[] goComps = go.GetComponents<Component>();
						for (int cI = 0; cI < goComps.Length; cI++)
						{
							string cTypeName = goComps[cI].GetType().ToString();
							string[] splitCTypeName = cTypeName.Split('.');
							cTypeName = splitCTypeName[splitCTypeName.Length - 1];
							if (cTypeName.ToLower().StartsWith(splitDots[1].ToLower()))
							{
								foundComponentNames.Add(cTypeName);
							}
						}
					}
					
					if (tagList.Any(item => item == splitDots[0]))
						gol = GameObject.FindGameObjectsWithTag(splitDots[0]).ToList();
					
					if (gol.Count > 0)
					{
						Dictionary<int, List<Component>> objectComponents = new Dictionary<int, List<Component>>();
						List<Component> goComps;
						
						foreach(GameObject g in gol)
							objectComponents.Add(g.GetInstanceID(), g.GetComponents<Component>().ToList());
						
						goComps = objectComponents.Values.FirstOrDefault();
						
						foreach(KeyValuePair<int, List<Component>> tempKVP in objectComponents)
						{
							for(int i = 0; i < goComps.Count; i++)
								if (!tempKVP.Value.Find(item => item.name == goComps[i].name))
									goComps.RemoveAt(i);
						}
						
						for (int cI = 0; cI < goComps.Count; cI++)
						{
							string cTypeName = goComps[cI].GetType().ToString();
							string[] splitCTypeName = cTypeName.Split('.');
							cTypeName = splitCTypeName[splitCTypeName.Length - 1];
							if (cTypeName.ToLower().StartsWith(splitDots[1].ToLower()))
							{
								foundComponentNames.Add(cTypeName);
							}
						}
					}
				}
			}
			if ( splitDots.Length == 3 )
			{
				if (!onlyAcceptAliases)
				{
					Component component = null;
					
					go = GameObject.Find(splitDots[0]);
					if (go != null)
					{
						component = go.GetComponent(splitDots[1]) as Component;
					}
					
					if (tagList.Any(item => item == splitDots[0]))
						gol = GameObject.FindGameObjectsWithTag(splitDots[0]).ToList();
					
					if (gol.Count > 0)
					{
						component = gol[0].GetComponent(splitDots[1]);
					}
					
					if (component != null)
					{
						MethodInfo[] mInfos = (component.GetType()).GetMethods();
						foreach (MethodInfo mInfo in mInfos)
						{
							if (mInfo.Name.ToLower().StartsWith(splitDots[2].ToLower()))
							{
								if (!foundMethodNames.Contains(mInfo.Name))
									foundMethodNames.Add(mInfo.Name);
							}
						}
						FieldInfo[] fInfos = (component.GetType()).GetFields();
						foreach (FieldInfo fInfo in fInfos)
						{
							if (fInfo.Name.ToLower().StartsWith(splitDots[2].ToLower()))
							{
								if (!foundFieldNames.Contains(fInfo.Name))
									foundFieldNames.Add(fInfo.Name);
							}
						}
						PropertyInfo[] pInfos = (component.GetType()).GetProperties();
						foreach (PropertyInfo pInfo in pInfos)
						{
							if (pInfo.Name.ToLower().StartsWith(splitDots[2].ToLower()))
							{
								if (!foundPropertyNames.Contains(pInfo.Name))
									foundPropertyNames.Add(pInfo.Name);
							}
						}
					}
				}
			}
			
			if ( foundGameObjectNames.Count > 0 || foundComponentNames.Count > 0 || foundMethodNames.Count > 0 )
			{
				showingAutocomplete = true;
			}
		}
		
		previousConsoleText = consoleText;
	}