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


C# Object.GetType方法代码示例

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


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

示例1: DestroyObject

 public new void DestroyObject(Object target)
 {
     if (target.GetType() == typeof(Transform))
         ObjectPooler.Deposit(((Transform)target).gameObject);
     else if (target.GetType() == typeof(GameObject))
         ObjectPooler.Deposit((GameObject)target);
     else
         Destroy(target);
 }
开发者ID:Evellex,项目名称:Eldrinth,代码行数:9,代码来源:GenericEventAction.cs

示例2: OnGUI

		public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {
			battribute = attribute as ButtonAttribute;
			obj = property.serializedObject.targetObject;
			MethodInfo method = obj.GetType().GetMethod(battribute.methodName, battribute.flags);
			
			if (method == null) {
				EditorGUI.HelpBox(position, "Method Not Found", MessageType.Error);
				
			} else {
				if (battribute.useValue) {
					valueRect = new Rect(position.x, position.y, position.width/2f, position.height);
					buttonRect = new Rect(position.x + position.width/2f, position.y, position.width/2f, position.height);
					
					EditorGUI.PropertyField(valueRect, property, GUIContent.none);
					if (GUI.Button(buttonRect, battribute.buttonName)) {
						method.Invoke(obj, new object[]{fieldInfo.GetValue(obj)});
					}
					
				} else {
					if (GUI.Button(position, battribute.buttonName)) {
						method.Invoke(obj, null);
					}
				}
			}
		}
开发者ID:OmegaDEVAU,项目名称:Simulator,代码行数:25,代码来源:ButtonDrawer.cs

示例3: ScreenShotComponent

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

示例4: OnXGUI

        public override void OnXGUI()
        {
            DoButton( "OpenMonoScript", OpenMonoScript );

            DoButton( "Clear", () => ScriptFile = null );

            ScriptFile = CreateObjectField( ScriptFile );

            flags = (BindingFlags)CreateEnumPopup( "BindingFlags", flags );

            if( null != ScriptFile ) {

                Type scriptType = ScriptFile.GetType();

                CreateLabel( "Fields" );
                if( scriptType == typeof( MonoScript ) ) {
                    scriptType = ( ScriptFile as MonoScript ).GetClass();
                }
                ShowMemberInfo( scriptType.GetFields( flags ) );

                CreateLabel( "Properties" );
                ShowMemberInfo( scriptType.GetProperties( flags ) );

                CreateLabel( "Members" );
                ShowMemberInfo( scriptType.GetMembers( flags ) );
            }
        }
开发者ID:wuxingogo,项目名称:WuxingogoExtension,代码行数:27,代码来源:CodeReviewEditor.cs

示例5: AddInputListener

 public static void AddInputListener(Object c)
 {
     foreach (var elem in c.GetType().GetFields()) {
         if (elem.FieldType==typeof (key))
             AddInput((key) elem.GetValue(c), elem.Name);
         else if (elem.FieldType==typeof (axis))
             AddInput((axis) elem.GetValue(c), elem.Name);
     }
 }
开发者ID:evan-erdos,项目名称:pathways,代码行数:9,代码来源:Controls.cs

示例6: Init

 public void Init(Object targetObject)
 {
     this.targetObject = targetObject;
     methods = targetObject.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(m =>
      m.GetCustomAttributes(typeof(ButtonAttribute), false).Length == 1 &&
      m.GetParameters().Length == 0 &&
      !m.ContainsGenericParameters
     ).ToList();
 }
开发者ID:Barnaff,项目名称:Chromania,代码行数:9,代码来源:BehaviourButtonsEditor.cs

示例7: SetSelectedStructure

 public void SetSelectedStructure(Object asset)
 {
     if(asset != null && asset.GetType() == typeof(TileStructureScriptableObject))
     {
         tileStructureScriptableObject = (TileStructureScriptableObject)asset;
     }
     else
     {
         tileStructureScriptableObject = null;
     }
 }
开发者ID:devolin,项目名称:gamedev,代码行数:11,代码来源:TileStructureEditorWindow.cs

示例8: PrintObject

			public void PrintObject(Object o, int recursionDepth = 0) {
				var asComponent = o as Component;
				var asGameObject = o as GameObject;
				if (asComponent == null && asGameObject == null) {
					_writer.WriteLine("{0} : {1}", o.GetType(), o.name);
					_writer.Indent++;
					PrintObjectMembers(o);
					_writer.Indent--;
					return;
				}
				if (asComponent != null) {
					asGameObject = asComponent.gameObject;
				}
				PrintUnityGameObject(asGameObject, recursionDepth);
			}
开发者ID:Bigtuna00,项目名称:IEMod.pw,代码行数:15,代码来源:UnityObjectDumper.cs

示例9: ShowInspectorForSerializedObject

        public static void ShowInspectorForSerializedObject(UnityObject target)
        {
            DrawOpenScriptButton(target);

            // Run the editor
            BehaviorEditor.Get(target.GetType()).EditWithGUILayout(target);

            // Inspector for the serialized state
            var inspectedObject = target as ISerializedObject;
            if (inspectedObject != null) {
                EditorGUI.BeginChangeCheck();
                DrawSerializedState(inspectedObject);
                if (EditorGUI.EndChangeCheck()) {
                    EditorUtility.SetDirty(target);
                    inspectedObject.RestoreState();
                }
            }
        }
开发者ID:JoeYarnall,项目名称:something-new,代码行数:18,代码来源:FullInspectorCommonSerializedObjectEditor.cs

示例10: OnTargetAssetChanged

        private IEnumerator OnTargetAssetChanged( Object asset )
        {
            string assetPath = AssetDatabase.GetAssetPath( asset );
            EditorSupport.ESUtility.CurRootPath = assetPath.Substring( 0, assetPath.IndexOf( "/res/", StringComparison.Ordinal ) + 1 );//+1是为了把"/"包含进去
            if( asset is ScriptableObject ){
                Type editorType = Utility.GetCustomEditor( asset.GetType() );
                BaseEditor_ = Editor.CreateEditor( asset, editorType ) as BaseEditor;
                if( BaseEditor_ ){
                    RawAsset_ = asset;
                    BaseEditor_.RawAsset = asset;
                }
                else{
                    LastError_ = "不是自定义格式的资源:" + assetPath;
                }
            }
            else{
                EditorWww www = EditorWww.Create( assetPath );
                while ( !www.Finished ) {
                    yield return null;
                }
                var scriptableObj = www.GetAsset() as ScriptableObject;
                www.Unload();
                if ( !scriptableObj ){
                    LastError_ = "无法识别的资源: " + assetPath;
                    yield break;
                }

                Type editorType = Utility.GetCustomEditor( scriptableObj.GetType() );
                if ( editorType == null || editorType.BaseType != typeof( BaseEditor ) ) {
                    LastError_ = "没有找到对应的编辑器: " + scriptableObj.GetType();
                }
                else {
                    ScriptableObject tempObj = CreateInstance( scriptableObj.GetType() );
                    EditorUtility.CopySerialized( scriptableObj, tempObj );
                    string filePath = Path.ChangeExtension( assetPath, PalmPoineer.Defines.AssetExt.UnityAsset );
                    AssetDatabase.CreateAsset( tempObj, filePath );
                    RawAsset_ = tempObj;
                    BaseEditor_ = Editor.CreateEditor( tempObj, editorType ) as BaseEditor;
                    BaseEditor_.RawAsset = tempObj;
                }
            }
        }
开发者ID:qingsheng1355,项目名称:test,代码行数:42,代码来源:CustomEditorWindow.cs

示例11: OnTargetAssetChanged

 private IEnumerator OnTargetAssetChanged(Object asset)
 {
     string assetPath = AssetDatabase.GetAssetPath(asset);
     //Debug.Log("OnTargetAssetChanged(), assetPath : " + assetPath);
     EditorSupport.ESUtility.CurRootPath = assetPath.Substring(0, assetPath.IndexOf("/res/", StringComparison.Ordinal) + 1);//+1是为了把"/"包含进去
     //Debug.Log("OnTargetAssetChanged(), CurRootPath : " + EditorSupport.ESUtility.CurRootPath);
     if (asset is ScriptableObject) {
         Type editorType = Utility.GetCustomEditor(asset.GetType());
         BaseEditor_ = Editor.CreateEditor(asset, editorType) as BaseEditor;
         if (BaseEditor_) {
             ObjFieldShow_ = asset;
             BaseEditor_.RawAsset = asset;
         }
         else {
             LastError_ = "不是自定义格式的资源:" + assetPath;
         }
     }
     else {
         yield return null;
     }
 }
开发者ID:qingsheng1355,项目名称:test,代码行数:21,代码来源:SceneEditorWindow.cs

示例12: EditorTools

        static EditorTools()
        {
            System.Type internalEditorUtilityType = typeof(InternalEditorUtility);

            sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
            sortingLayerUniqueIDsProperty = internalEditorUtilityType.GetProperty("sortingLayerUniqueIDs", BindingFlags.Static | BindingFlags.NonPublic);
            getSortingLayerCountMethod = internalEditorUtilityType.GetMethod( "GetSortingLayerCount",BindingFlags.Static | BindingFlags.NonPublic );
            #if UNITY_5
            getSortingLayerUniqueIDMethod = internalEditorUtilityType.GetMethod( "GetSortingLayerUniqueID",BindingFlags.Static | BindingFlags.NonPublic );
            #else
            getSortingLayerUserIDMethod = internalEditorUtilityType.GetMethod( "GetSortingLayerUserID",BindingFlags.Static | BindingFlags.NonPublic );
            #endif
            getSortingLayerNameFromUniqueIDMethod = internalEditorUtilityType.GetMethod( "GetSortingLayerNameFromUniqueID",BindingFlags.Static | BindingFlags.NonPublic );
            getSortingLayerNameMethod = internalEditorUtilityType.GetMethod( "GetSortingLayerName",BindingFlags.Static | BindingFlags.NonPublic );

            System.Type editorApplicationType = typeof(EditorApplication);

            PropertyInfo tagManagerProperty = editorApplicationType.GetProperty( "tagManager",BindingFlags.Static | BindingFlags.NonPublic);

            tagManager = (Object)tagManagerProperty.GetValue( null,new object[0] );

            defaultExpandedFoldoutField = tagManager.GetType().GetField( "m_DefaultExpandedFoldout" );
        }
开发者ID:sgmtjp,项目名称:Git-SODATERUTOWER,代码行数:23,代码来源:EditorTools.cs

示例13: GetObjectType

        private static ObjectType GetObjectType(Object activeObject)
        {
            if (activeObject == null) return ObjectType.None;

            if (activeObject is GameObject)
            {
				if (Instance._breadcrumbs != null)
					if (activeObject == Instance._breadcrumbs.gameObject) return ObjectType.InspectorBreadcrumbs;

                PrefabType pt = PrefabUtility.GetPrefabType((GameObject)activeObject);
                if (pt == PrefabType.None || pt == PrefabType.DisconnectedModelPrefabInstance || pt == PrefabType.DisconnectedPrefabInstance ||
                    pt == PrefabType.MissingPrefabInstance || pt == PrefabType.ModelPrefabInstance || pt == PrefabType.PrefabInstance) 
                    return ObjectType.Instance;
            }

            if (activeObject as UnityEngine.TextAsset != null)
                return ObjectType.TextAssets;
            
            if (activeObject.ToString().Contains("UnityEngine.SceneAsset"))
                return ObjectType.Scene;

            var asset_path = AssetDatabase.GetAssetPath(activeObject);
            if (string.IsNullOrEmpty(asset_path))
            {
                if (activeObject.GetType().ToString().Contains("AssetStoreAssetInspector"))
                    return ObjectType.AssetStoreAssetInspector;
                else
                    return ObjectType.Asset;
            }
            if (asset_path.StartsWith("ProjectSettings/")) return ObjectType.ProjectSettings;
                
            try
            {
                System.IO.FileAttributes file_attr = System.IO.File.GetAttributes(Application.dataPath + "/" + asset_path.Replace("Assets/", ""));
                if ((file_attr & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory)
                    return ObjectType.Folder;
            }
            catch { }

            return ObjectType.Asset;
        }
开发者ID:howkj1,项目名称:fleecenavidad,代码行数:41,代码来源:InspectorNavigator.cs

示例14: WriteUnityObjectData

 private void WriteUnityObjectData( string depth, Object uo, bool seen )
 {
     // shows some additional info on UnityObjects
     writer.WriteLine( depth + "<unityObject type=\"{0}\" name=\"{1}\" seen=\"{2}\" hash=\"{3}\"/>",
                       SecurityElement.Escape( uo.GetType().GetFormattedName() ),
                       SecurityElement.Escape( uo ? uo.name : "--missing reference--" ),
                       seen,
                       uo ? uo.GetHashCode().ToString() : "0");
     // todo we can show referenced assets for renderers, materials, audiosources etc
 }
开发者ID:kaienkira,项目名称:UnityHeapEx,代码行数:10,代码来源:HeapDump.cs

示例15: GetPlaceholder

        /// <summary>
        /// Create a PlaceHolder object for a given Component.  We can reference this component later.
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>
        private static Object GetPlaceholder( SubScene subScene, Object originalObj, string hashId )
        {
            string name = string.Format( "Cross-Scene Ref ({0})", hashId );
            GameObject newGameObj = null;

            SceneData sceneData = SceneDataEx.GetSceneData(subScene);

            // First try searching by name (old behaviour)
            Transform existsChild = sceneData.transform.FindChild( name );
            if ( existsChild )
                newGameObj = existsChild.gameObject;

            if ( !newGameObj )
            {
                newGameObj = EditorUtility.CreateGameObjectWithHideFlags( name, HideFlags.None );
                newGameObj.transform.parent = sceneData.transform;
                newGameObj.SetActive(false);

				SubSceneEx.SetIsDirty( subScene, true );
            }

            if ( !AdditiveScenePreferences.DebugShowBookkepingObjects )
                newGameObj.hideFlags = HideFlags.HideInHierarchy;

            // Create a new, cloned component on the current GameObject.
            if ( originalObj is GameObject )
            {
                return newGameObj;
            }
            else if ( originalObj is Transform )
            {
                return newGameObj.transform;
            }
            else if ( originalObj is Component )
            {
                Component component = (Component)originalObj;
                Unsupported.CopyComponentToPasteboard( component );

                Component newComp = newGameObj.GetComponent( originalObj.GetType() );
                if ( !newComp )
				{
                    newComp = newGameObj.AddComponent( component.GetType() );
					SubSceneEx.SetIsDirty( subScene, true );
				}

                Unsupported.PasteComponentValuesFromPasteboard( newComp );
                return newComp;
            }

            throw new System.ArgumentException( "Placeholders can only be created for GameObjects or Components", "originalObj" );
        }
开发者ID:santiamchristian,项目名称:compro2016,代码行数:56,代码来源:AmsCrossSceneReferencesEx.cs


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