当前位置: 首页>>代码示例>>C#>>正文


C# GameObject.GetType方法代码示例

本文整理汇总了C#中UnityEngine.GameObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.GetType方法的具体用法?C# GameObject.GetType怎么用?C# GameObject.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.GameObject的用法示例。


在下文中一共展示了GameObject.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBooleanMethodsFrom

 public List<MethodInfo> GetBooleanMethodsFrom(GameObject gameObject)
 {
     List<MethodInfo> booleanMethods = new List<MethodInfo> ();
     //GameObject boolean methods
     foreach(MethodInfo mo in gameObject.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public)) {
         if(mo.GetParameters().Length==0
            && mo.ReturnType == typeof(Boolean)) {
             booleanMethods.Add(mo);
         }
     }
     //Component of gameObject boolean methods
     Component[] comps = gameObject.GetComponents<Component>();
     foreach (Component comp in comps) {
         if(comp==null)
             continue;
         MethodInfo[] methods = comp.GetType ().GetMethods (BindingFlags.Instance | BindingFlags.Public);
         foreach(MethodInfo mi in methods) {
             if(mi.GetParameters().Length==0
                && mi.ReturnType == typeof(Boolean))
                 booleanMethods.Add (mi);
         }
     }
     return booleanMethods;
 }
开发者ID:TsubameDono,项目名称:Evolution,代码行数:24,代码来源:SerenityMethodTriggerEditor.cs

示例2: GetGamePropertyValue

 private object GetGamePropertyValue(GameObject game)
 {
     if (game == null) return null;
     Dictionary<string, object> objectInfo = new Dictionary<string, object>();
     objectInfo.Add("type", game.GetType().FullName);
     objectInfo.Add("id", GetID(game));
     objectInfo.Add("tag", game.tag);
     objectInfo.Add("name", game.name);
     objectInfo.Add("layer", game.layer);
     objectInfo.Add("isStatic", game.isStatic);
     objectInfo.Add("hideFlags", game.hideFlags.ToString());
     return objectInfo;
 }
开发者ID:BabylonJS,项目名称:Babylon.js,代码行数:13,代码来源:SceneBuilder.cs

示例3: PrintUnityGameObject

		private void PrintUnityGameObject(GameObject o, IndentedTextWriter writer, Func<GameObject, bool> gameObjectFilter, Func<Component, bool> componentFilter) {
			if (o == null) {
				writer.WriteLine("(null)");
				return;
			}
			
			writer.WriteLine("{0} : {1}", o.GetType(), o.name);
			if (_visited.ContainsKey(o)) {
				writer.Write(" (already dumped)");
				return;
			}
			writer.Indent++;
			writer.WriteLine("Components:");
			writer.Indent++;
			
			_visited[o] = true;
			foreach (var component in o.GetComponents(typeof (Component))) {
				writer.WriteLine("[Component] {0}", component.GetType().Name);
				if (!componentFilter(component)) continue;
				writer.Indent++;
				PrintObjectMembers(writer, component);
				writer.Indent--;
			}
			writer.Indent--;
			writer.WriteLine("Children:");

			var numChildren = o.transform.childCount;
			for (int i = 0; i < numChildren; i++) {
				var child = o.transform.GetChild(i);
				writer.Indent++;
				writer.Write("{0}. [Child] ", i);
				if (gameObjectFilter(child.gameObject)) {
					PrintUnityGameObject(child.gameObject, writer, gameObjectFilter, componentFilter);	
				}
				
				writer.Indent--;
			}
			writer.Indent--;
		}
开发者ID:RAlexander4287,项目名称:IEMod.pw,代码行数:39,代码来源:UnityObjectDumper.cs

示例4: GetPropertyTypeFromString

		private static Type GetPropertyTypeFromString(GameObject gameObj, string propertyPath)
		{
			if (propertyPath == "")
				return gameObj.GetType();

			var propsQueue = new Queue<string>(propertyPath.Split('.').Where(s => !string.IsNullOrEmpty(s)));

			if (propsQueue == null) throw new ArgumentException("Incorrent property path");

			Type result;
			if (char.IsLower(propsQueue.Peek()[0]))
			{
				result = gameObj.GetType();
			}
			else
			{
				var component = gameObj.GetComponent(propsQueue.Dequeue());

				if (component == null) throw new ArgumentException("Incorrent property path");

				result = component.GetType();
			}
			while (propsQueue.Count != 0)
			{
				var nameToFind = propsQueue.Dequeue();

				var property = result.GetProperty(nameToFind);
				if (property != null)
				{
					result = property.PropertyType;
				}
				else
				{
					var field = result.GetField(nameToFind);
					if (field == null) throw new ArgumentException("Incorrent property path");
					result = field.FieldType;
				}
			}
			return result;
		}
开发者ID:eyalzur,项目名称:CodeSamplesPublic,代码行数:40,代码来源:PropertyResolver.cs

示例5: PrintUnityGameObject

			public void PrintUnityGameObject(GameObject o, int recursionDepth = 0) {
				if (o == null) {
					_writer.WriteLine("(null)");
					return;
				}
				_writer.Write("{0} : {1}", o.GetType(), o.name);
				if (_visited.ContainsKey(o)) {
					_writer.WriteLine(" (already dumped)");
					return;
				}
				if (recursionDepth >= _parent.MaxRecursionDepth) {
					_writer.WriteLine(" (recursion depth exceeded)");
					return;
				}
				_writer.WriteLine();
				_writer.Indent++;
				_writer.WriteLine($"Parent: {o.transform.parent?.name}");
				_writer.WriteLine("Components:");
				_writer.Indent++;

				_visited[o] = true;
				foreach (var component in o.Components(typeof (Component))) {
					_writer.WriteLine("[Component] {0}", component.GetType().Name);
					if (!_parent.ComponentFilter(component)) continue;
					_writer.Indent++;
					PrintObjectMembers(component);
					_writer.Indent--;
				}
				_writer.Indent--;
				_writer.WriteLine("Children:");

				var numChildren = o.transform.childCount;
				for (int i = 0; i < numChildren; i++) {
					var child = o.transform.GetChild(i);
					_writer.Write("{0}.\t [Child] ", i);
					if (_parent.GameObjectFilter(child.gameObject)) {
						PrintUnityGameObject(child.gameObject, recursionDepth + 1);
					}
				}
				_writer.Indent--;
			}
开发者ID:Bigtuna00,项目名称:IEMod.pw,代码行数:41,代码来源:UnityObjectDumper.cs


注:本文中的UnityEngine.GameObject.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。