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


C# UnityEngine.GetType方法代码示例

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


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

示例1: OnGUI

		public static void OnGUI(UnityEngine.Object targetObject){
			EditorGUI.BeginChangeCheck ();
			SerializedObject serializedObject = new SerializedObject (targetObject);
			serializedObject.Update ();
			FieldInfo[] fields;
			if(!fieldsLookup.TryGetValue (targetObject.GetType (),out fields)){
				fields=targetObject.GetPublicFields().OrderBy(field => field.MetadataToken).ToArray();

				fieldsLookup.Add(targetObject.GetType(),fields);
			}
			if(PreferencesEditor.GetBool(Preference.ShowActionTooltips) && !string.IsNullOrEmpty(targetObject.GetTooltip())){
				GUILayout.BeginVertical((GUIStyle)"hostview");

				GUILayout.Label(targetObject.GetTooltip(),FsmEditorStyles.wrappedLabelLeft);
				GUILayout.EndVertical();
			}


			for (int i=0; i< fields.Length; i++) {
				FieldInfo field=fields[i];
				if(field.HasAttribute(typeof(HideInInspector))){
					continue;
				}
				PropertyDrawer drawer=GUIDrawer.GetDrawer(field);
				GUIContent content = field.GetInspectorGUIContent ();
				SerializedProperty property=serializedObject.FindProperty(field.Name);
				if(PreferencesEditor.GetBool(Preference.ShowVariableTooltips) && !string.IsNullOrEmpty(field.GetTooltip())){
					GUILayout.BeginVertical("box");
					GUILayout.Label(field.GetTooltip(),FsmEditorStyles.wrappedLabelLeft);
					GUILayout.EndVertical();
				}

				if(drawer != null){
					drawer.fieldInfo=field;
					drawer.OnGUI(property,content);
				}else{
					int indentLevel=EditorGUI.indentLevel;
					EditorGUI.indentLevel=	typeof(IList).IsAssignableFrom(field.FieldType)?indentLevel+1:indentLevel;
					EditorGUILayout.PropertyField (property, content,true);
					EditorGUI.indentLevel=indentLevel;
				}
			}


			if (EditorGUI.EndChangeCheck()) {
				serializedObject.ApplyModifiedProperties();
				ErrorChecker.CheckForErrors();
			}
		}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:49,代码来源:GUIDrawer.cs

示例2: ScreenShotComponent

		public static void ScreenShotComponent(Rect contentRect, UnityEngine.Object target)
		{
			ScreenShots.s_TakeComponentScreenshot = false;
			contentRect.yMax += 2f;
			contentRect.xMin += 1f;
			ScreenShots.SaveScreenShotWithBorder(contentRect, ScreenShots.kWindowBorderColor, target.GetType().Name + "Inspector");
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:7,代码来源:ScreenShots.cs

示例3: InitializeControlFreakTouchController

    protected virtual void InitializeControlFreakTouchController(UnityEngine.Object touchController)
    {
        if (touchController != null){
            Type inputType = touchController.GetType();

            if (inputType != null){
                this.deadZone = UFE.config.inputOptions.controlFreakDeadZone;
                this.useControlFreak = true;

                // Retrieve the required methods using the Reflection API to avoid
                // compilation errors if Control-Freak's TouchController hasn't been
                // imported into the project. We will cache the method information
                // to call these methods later
                MethodInfo getAxisInfo = inputType.GetMethod(
                    "GetAxis",
                    BindingFlags.Instance | BindingFlags.Public,
                    null,
                    new Type[]{typeof(string)},
                    null
                );

                if (getAxisInfo != null){
                    this.getAxis = delegate(string axis){
                        return (float) getAxisInfo.Invoke(touchController, new object[]{axis});
                    };
                }

                MethodInfo getAxisRawInfo = inputType.GetMethod(
                    "GetAxisRaw",
                    BindingFlags.Instance | BindingFlags.Public,
                    null,
                    new Type[]{typeof(string)},
                    null
                );

                if (getAxisRawInfo != null){
                    this.getAxisRaw = delegate(string axis){
                        return (float) getAxisRawInfo.Invoke(touchController, new object[]{axis});
                    };
                }

                MethodInfo getButtonInfo = inputType.GetMethod(
                    "GetButton",
                    BindingFlags.Instance | BindingFlags.Public,
                    null,
                    new Type[]{typeof(string)},
                    null
                );

                if (getButtonInfo != null){
                    this.getButton = delegate(string button){
                        return (bool) getButtonInfo.Invoke(touchController, new object[]{button});
                    };
                }
            }
        }
    }
开发者ID:Reshille,项目名称:Gentlemanners,代码行数:57,代码来源:InputTouchController.cs

示例4: CheckForErrors

		public static void CheckForErrors(UnityEngine.Object targetObject){
			if (targetObject == null) {
				return;
			}
			if (targetObject.GetType ()==typeof(StateMachine)) {
				checkingStateMachine = targetObject as StateMachine;			
			}else if(targetObject.GetType()==typeof(State)){
				checkingState=targetObject as State;
			} else if (targetObject.GetType ().IsSubclassOf (typeof(ExecutableNode))) {
				checkingExecutableNode=targetObject as ExecutableNode;			
			}

			FieldInfo[] fields = targetObject.GetType().GetAllFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
			for (int i=0; i<fields.Length; i++) {
				FieldInfo field=fields[i];
				if(field.HasAttribute(typeof(ReferenceAttribute)) || !field.IsSerialized()){
					continue;
				}
				object value=field.GetValue(targetObject);
				if(field.FieldType.IsSubclassOf(typeof(FsmVariable))){
					if(!field.HasAttribute(typeof(NotRequiredAttribute)) &&(value == null || CheckForVariableError(value as FsmVariable,field))){
						FsmError error=new FsmError(FsmError.ErrorType.RequiredField,checkingStateMachine,checkingState,checkingExecutableNode,value as FsmVariable,field);
						if(!ContainsError(error)){
							errorList.Add(error);
						}
					}
				}else if(field.FieldType.IsSubclassOf(typeof(UnityEngine.Object))){
					CheckForErrors(value as UnityEngine.Object);
				}else if(field.FieldType.IsArray){
					var array = value as Array;
					Type elementType = field.FieldType.GetElementType ();
					if(elementType.IsSubclassOf(typeof(UnityEngine.Object))){
						foreach(UnityEngine.Object element in array){
							CheckForErrors(element);
						}
					}
				}
			}
			checkForErrors = false;
		}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:40,代码来源:ErrorChecker.cs

示例5: LogSingleInstance

        public static void LogSingleInstance(UnityEngine.Object instanceToLog, params object[] toLog)
        {
            int instanceId;

            if (instanceDict.TryGetValue(instanceToLog.GetType(), out instanceId))
            {
                if (instanceId == instanceToLog.GetInstanceID())
                    Log(toLog);
            }
            else
            {
                instanceDict[instanceToLog.GetType()] = instanceToLog.GetInstanceID();
                Log(toLog);
            }
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:15,代码来源:PDebug.cs

示例6: GetTypeName

 internal static string GetTypeName(UnityEngine.Object obj)
 {
   if (obj == (UnityEngine.Object) null)
     return "Object";
   string lower = AssetDatabase.GetAssetPath(obj).ToLower();
   if (lower.EndsWith(".unity"))
     return "Scene";
   if (lower.EndsWith(".guiskin"))
     return "GUI Skin";
   if (Directory.Exists(AssetDatabase.GetAssetPath(obj)))
     return "Folder";
   if (obj.GetType() == typeof (UnityEngine.Object))
     return Path.GetExtension(lower) + " File";
   return ObjectNames.GetClassName(obj);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:15,代码来源:ObjectNames.cs

示例7: GetTypeName

		internal static string GetTypeName(UnityEngine.Object obj)
		{
			string text = AssetDatabase.GetAssetPath(obj).ToLower();
			if (text.EndsWith(".unity"))
			{
				return "Scene";
			}
			if (text.EndsWith(".guiskin"))
			{
				return "GUI Skin";
			}
			if (Directory.Exists(AssetDatabase.GetAssetPath(obj)))
			{
				return "Folder";
			}
			if (obj.GetType() == typeof(UnityEngine.Object))
			{
				return Path.GetExtension(text) + " File";
			}
			return ObjectNames.GetClassName(obj);
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:21,代码来源:ObjectNames.cs

示例8: ValidateEditor

	/// <summary>
	/// this class will call the validate method of the inspector
	/// </summary>
	/// <param name="theGameObject"></param>
	public static KGFMessageList ValidateEditor(UnityEngine.Object theObject)
	{
		KGFMessageList aMessageList = new KGFMessageList();
		string anObjectName = theObject.GetType().ToString();
		string aTypeName = anObjectName+"Editor";
		Type aType = Type.GetType(aTypeName);
		if(aType != null)
		{
			MethodInfo aMethodInfo = aType.GetMethod("Validate"+aTypeName,System.Reflection.BindingFlags.Static | BindingFlags.Public);
			if(aMethodInfo != null && aMethodInfo.GetParameters().Length == 1)
			{
				object[] aParameters = new object[1];
				aParameters[0] = theObject;
				aMessageList = (KGFMessageList)aMethodInfo.Invoke(null,aParameters);
			}
			else
			{
				if (!itsAlreadySentWarnings.Contains(aTypeName))
				{
					itsAlreadySentWarnings.Add(aTypeName);
					aMessageList.AddWarning("static method Validate"+aTypeName+"() not implemented in: "+aTypeName);
					Debug.LogWarning("static method Validate() not implemented in: "+aTypeName);
				}
			}
		}
		else
		{
			if (!itsAlreadySentWarnings.Contains(aTypeName))
			{
				itsAlreadySentWarnings.Add(aTypeName);
				aMessageList.AddWarning("type: "+aTypeName+" not implemented.");
				Debug.LogWarning("type: "+aTypeName+" not implemented.");
			}
		}
		return aMessageList;
	}
开发者ID:predominant,项目名称:Treasure_Chest,代码行数:40,代码来源:KGFEditor.cs

示例9: GeneratePopUpForType

 private static void GeneratePopUpForType(GenericMenu menu, UnityEngine.Object target, bool useFullTargetName, SerializedProperty listener, System.Type[] delegateArgumentsTypes)
 {
   List<UnityEventDrawer.ValidMethodMap> methods = new List<UnityEventDrawer.ValidMethodMap>();
   string targetName = !useFullTargetName ? target.GetType().Name : target.GetType().FullName;
   bool flag = false;
   if (delegateArgumentsTypes.Length != 0)
   {
     UnityEventDrawer.GetMethodsForTargetAndMode(target, delegateArgumentsTypes, methods, PersistentListenerMode.EventDefined);
     if (methods.Count > 0)
     {
       menu.AddDisabledItem(new GUIContent(targetName + "/Dynamic " + string.Join(", ", ((IEnumerable<System.Type>) delegateArgumentsTypes).Select<System.Type, string>((Func<System.Type, string>) (e => UnityEventDrawer.GetTypeName(e))).ToArray<string>())));
       UnityEventDrawer.AddMethodsToMenu(menu, listener, methods, targetName);
       flag = true;
     }
   }
   methods.Clear();
   UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1]{ typeof (float) }, methods, PersistentListenerMode.Float);
   UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1]{ typeof (int) }, methods, PersistentListenerMode.Int);
   UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1]{ typeof (string) }, methods, PersistentListenerMode.String);
   UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1]{ typeof (bool) }, methods, PersistentListenerMode.Bool);
   UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1]{ typeof (UnityEngine.Object) }, methods, PersistentListenerMode.Object);
   UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[0], methods, PersistentListenerMode.Void);
   if (methods.Count <= 0)
     return;
   if (flag)
     menu.AddItem(new GUIContent(targetName + "/ "), false, (GenericMenu.MenuFunction) null);
   if (delegateArgumentsTypes.Length != 0)
     menu.AddDisabledItem(new GUIContent(targetName + "/Static Parameters"));
   UnityEventDrawer.AddMethodsToMenu(menu, listener, methods, targetName);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:30,代码来源:UnityEventDrawer.cs

示例10: CalculateMethodMap

 private static IEnumerable<UnityEventDrawer.ValidMethodMap> CalculateMethodMap(UnityEngine.Object target, System.Type[] t, bool allowSubclasses)
 {
   List<UnityEventDrawer.ValidMethodMap> validMethodMapList = new List<UnityEventDrawer.ValidMethodMap>();
   if (target == (UnityEngine.Object) null || t == null)
     return (IEnumerable<UnityEventDrawer.ValidMethodMap>) validMethodMapList;
   System.Type type = target.GetType();
   List<MethodInfo> list = ((IEnumerable<MethodInfo>) type.GetMethods()).Where<MethodInfo>((Func<MethodInfo, bool>) (x => !x.IsSpecialName)).ToList<MethodInfo>();
   IEnumerable<PropertyInfo> source = ((IEnumerable<PropertyInfo>) type.GetProperties()).AsEnumerable<PropertyInfo>().Where<PropertyInfo>((Func<PropertyInfo, bool>) (x =>
   {
     if (x.GetCustomAttributes(typeof (ObsoleteAttribute), true).Length == 0)
       return x.GetSetMethod() != null;
     return false;
   }));
   list.AddRange(source.Select<PropertyInfo, MethodInfo>((Func<PropertyInfo, MethodInfo>) (x => x.GetSetMethod())));
   using (List<MethodInfo>.Enumerator enumerator = list.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       MethodInfo current = enumerator.Current;
       System.Reflection.ParameterInfo[] parameters = current.GetParameters();
       if (parameters.Length == t.Length && current.GetCustomAttributes(typeof (ObsoleteAttribute), true).Length <= 0 && current.ReturnType == typeof (void))
       {
         bool flag = true;
         for (int index = 0; index < t.Length; ++index)
         {
           if (!parameters[index].ParameterType.IsAssignableFrom(t[index]))
             flag = false;
           if (allowSubclasses && t[index].IsAssignableFrom(parameters[index].ParameterType))
             flag = true;
         }
         if (flag)
           validMethodMapList.Add(new UnityEventDrawer.ValidMethodMap()
           {
             target = target,
             methodInfo = current
           });
       }
     }
   }
   return (IEnumerable<UnityEventDrawer.ValidMethodMap>) validMethodMapList;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:41,代码来源:UnityEventDrawer.cs

示例11: FindCustomEditorType

 internal static System.Type FindCustomEditorType(UnityEngine.Object o, bool multiEdit)
 {
   return CustomEditorAttributes.FindCustomEditorTypeByType(o.GetType(), multiEdit);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:4,代码来源:CustomEditorAttributes.cs

示例12: HelpIconButton

 internal static bool HelpIconButton(Rect position, UnityEngine.Object obj)
 {
   bool flag1 = Unsupported.IsDeveloperBuild();
   bool defaultToMonoBehaviour = !flag1 || obj.GetType().Assembly.ToString().StartsWith("Assembly-");
   bool flag2 = Help.HasHelpForObject(obj, defaultToMonoBehaviour);
   if (!flag2 && !flag1)
     return false;
   Color color = GUI.color;
   GUIContent content = new GUIContent(EditorGUI.GUIContents.helpIcon);
   string helpNameForObject = Help.GetNiceHelpNameForObject(obj, defaultToMonoBehaviour);
   if (flag1 && !flag2)
   {
     GUI.color = Color.yellow;
     string str = (!(obj is MonoBehaviour) ? "sealed partial class-" : "script-") + helpNameForObject;
     content.tooltip = string.Format("Could not find Reference page for {0} ({1}).\nDocs for this object is missing or all docs are missing.\nThis warning only shows up in development builds.", (object) helpNameForObject, (object) str);
   }
   else
     content.tooltip = string.Format("Open Reference for {0}.", (object) helpNameForObject);
   GUIStyle inspectorTitlebarText = EditorStyles.inspectorTitlebarText;
   if (GUI.Button(position, content, inspectorTitlebarText))
     Help.ShowHelpForObject(obj);
   GUI.color = color;
   return true;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:24,代码来源:EditorGUI.cs

示例13: GetMethod

    internal protected static bool GetMethod(UnityEngine.MonoBehaviour monob, string methodType, out MethodInfo mi)
    {
        mi = null;

        if (monob == null || string.IsNullOrEmpty(methodType))
        {
            return false;
        }

        List<MethodInfo> methods = SupportClass.GetMethods(monob.GetType(), null);
        for (int index = 0; index < methods.Count; index++)
        {
            MethodInfo methodInfo = methods[index];
            if (methodInfo.Name.Equals(methodType))
            {
                mi = methodInfo;
                return true;
            }
        }

        return false;
    }
开发者ID:Awesome-MQP,项目名称:Storybook,代码行数:22,代码来源:NetworkingPeer.cs

示例14: GetAssetId

 public SaveGameManager.AssetReference GetAssetId(UnityEngine.Object referencedObject)
 {
     if (referencedObject == null)
     {
         return new SaveGameManager.AssetReference
         {
             index = -1
         };
     }
     Index<string, List<UnityEngine.Object>> index = null;
     Type type = referencedObject.GetType();
     if (!this.assetReferences.TryGetValue(type, out index))
     {
         index = (this.assetReferences[type] = new Index<string, List<UnityEngine.Object>>());
         IEnumerable<UnityEngine.Object> enumerable = Resources.FindObjectsOfTypeAll(type).Except(UnityEngine.Object.FindObjectsOfType(type));
         foreach (UnityEngine.Object current in enumerable)
         {
             index[current.name].Add(current);
         }
     }
     List<UnityEngine.Object> list = null;
     if (!index.TryGetValue(referencedObject.name, out list))
     {
         return new SaveGameManager.AssetReference
         {
             index = -1
         };
     }
     return new SaveGameManager.AssetReference
     {
         index = list.IndexOf(referencedObject),
         name = referencedObject.name,
         type = type.FullName
     };
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:35,代码来源:SaveGameManager.cs

示例15: SerializeUnityObject

		/** Write a UnityEngine.Object */
		public void SerializeUnityObject ( UnityEngine.Object ob ) {
			
			if ( ob == null ) {
				writer.Write (int.MaxValue);
				return;
			}
			
			int inst = ob.GetInstanceID();
			string name = ob.name;
			string type = ob.GetType().AssemblyQualifiedName;
			string guid = "";
			
			//Write scene path if the object is a Component or GameObject
			Component component = ob as Component;
			GameObject go = ob as GameObject;
			
			if (component != null || go != null) {
				if (component != null && go == null) {
					go = component.gameObject;
				}
				
				UnityReferenceHelper helper = go.GetComponent<UnityReferenceHelper>();
				
				if (helper == null) {
					Debug.Log ("Adding UnityReferenceHelper to Unity Reference '"+ob.name+"'");
					helper = go.AddComponent<UnityReferenceHelper>();
				}
				
				//Make sure it has a unique GUID
				helper.Reset ();
				
				guid = helper.GetGUID ();
			}
			
			
			writer.Write(inst);
			writer.Write(name);
			writer.Write(type);
			writer.Write(guid);
		}
开发者ID:SpacesAdventure,项目名称:Kio-2,代码行数:41,代码来源:JsonSerializer.cs


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