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


C# MonoBehaviour.GetType方法代码示例

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


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

示例1: TraceRecursively

	static void TraceRecursively( MonoBehaviour _mono, GameObject _obj)
	{
		if( null == _obj)
			return;
		
		Transform parent = _obj.transform.parent;
		string log = "{R}" + _mono.GetType();
		
		while( true)
		{
			if( parent == null)
				break;
			
			bool concur = false;
			foreach( KeyValuePair<MonoBehaviour, GameObject> pair in s_dicObj)
			{
				if( pair.Value == parent.gameObject)
				{
					concur = true;
					break;
				}
			}
			
			if( concur == false)
				log = "< [ INVALID ] " + parent.name + " >/" + log;
			else
				log = "(" + parent.name + ")/" + log;

			parent = parent.parent;
		}
	}
开发者ID:ftcaicai,项目名称:ArkClient,代码行数:31,代码来源:DDOL_Tracer.cs

示例2: Process

 public static void Process(MonoBehaviour obj)
 {
     var type = obj.GetType();
     var fileds = type.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
     
     foreach(var filed in fileds)
     {
         var attribute = filed.GetCustomAttributes(typeof(ControlAttribute), true);
         if (attribute.Length == 0)
             continue;
         
         var controlAttribute = attribute[0] as ControlAttribute;
         if (controlAttribute == null)
             continue;
         
         if (!string.IsNullOrEmpty(controlAttribute.Name))
         {
             var control = GetControl(obj.gameObject, controlAttribute.Name, filed.FieldType);
             filed.SetValue(obj, control);
             continue;
         }
         
         if (!string.IsNullOrEmpty(controlAttribute.FullPath))
         {
             var control = GetControlByFullPath(obj.gameObject, controlAttribute.FullPath, filed.FieldType);
             filed.SetValue(obj, control);
             continue;
         }
     }
 }
开发者ID:dot123,项目名称:UnityUtils,代码行数:30,代码来源:ControlAttribute.cs

示例3: SendWithDelay

 public IEnumerator SendWithDelay(MonoBehaviour sender)
 {
     yield return new WaitForSeconds(delay);
     if (receiver)
         receiver.SendMessage(action);
     else
         Debug.LogWarning("No receiver of signal \"" + action + "\" on object " + sender.name + " (" + sender.GetType().Name + ")", sender);
 }
开发者ID:cn00,项目名称:U3D5_CSharp_AngryBots,代码行数:8,代码来源:SignalSender.cs

示例4: SerializeComponent

 private ComponentData SerializeComponent( MonoBehaviour component )
 {
     if( component != null )
     {
         ComponentData componentData = new ComponentData( component.GetType(), JsonUtility.ToJson( component ) );
         DestroyImmediate( component );
         return componentData;
     }
     return null;
 }
开发者ID:richardlord,项目名称:Unity-State-Machine,代码行数:10,代码来源:StateMachine.cs

示例5: AddToInventory

	public bool AddToInventory(MonoBehaviour item) {
		if (ItemInInventory(item))
			return false;
			
		inventory.Add(item);
		Debug.Log ("Adding a " + item.GetType().ToString() + " to inventory");
		UpdateSelectables();
		
		return true;
	}
开发者ID:benlewis,项目名称:unhinged_vr,代码行数:10,代码来源:InventoryManager.cs

示例6: logObjName

 public static string logObjName(MonoBehaviour objx )
 {
     GameObject obj = objx.gameObject;
     string objName = string.Format("{0}/{1} ",obj.name, objx.GetType().Name);
     while (obj.transform && obj.transform.parent)
     {
         obj = obj.transform.parent.gameObject;
         objName = string.Format("{0}/{1}", obj.name, objName);
     }
     return objName;
 }
开发者ID:ancongsheng,项目名称:vu_paradox,代码行数:11,代码来源:XUIActiveBase.cs

示例7: Start

    void Start()
    {
        EventPool eventPool = GameObject.FindObjectOfType<EventPool>();
        GameEvent playerFoundEvent;
        eventPool.GetEventFromPool("Player Found", out playerFoundEvent);
        playerFoundEvent.onHandleEvent += EventZoom;

        currentCamera = cameras[0];
        cameraType = currentCamera.GetType();
        cameraName.text = cameraType.ToString();
        description.text = "This camera follows the player rigidly and can zoom in and out\npress up/down arrows to increase/decrease";
    }
开发者ID:Nodgez,项目名称:Sneaky-Blocks,代码行数:12,代码来源:CameraTest.cs

示例8: ExamMonoBehaviour

    /// <summary>
    /// Exams the component to see if there is something not supported.
    /// Currently check List only.
    /// </summary>
    /// <param name="com">The component.</param>
    /// <returns>An error list.</returns>
    static List<string> ExamMonoBehaviour(MonoBehaviour com)
    {
        List<string> lstProblem = new List<string>();
        //StringBuilder sbProblem = new StringBuilder();
        MonoBehaviour behaviour = com as MonoBehaviour;
        //Type type = behaviour.GetType();
        FieldInfo[] fields = JSSerializerEditor.GetMonoBehaviourSerializedFields(behaviour);
        for (var i = 0; i < fields.Length; i++)
        {
            FieldInfo field = fields[i];
            Type fieldType = field.FieldType;
            if (fieldType.IsArray)
            {
                fieldType = fieldType.GetElementType();
            }
            // ! List is not supported
            // 
            if (fieldType.IsGenericType)
            {
                lstProblem.Add(new StringBuilder().AppendFormat("{0} {1}.{2} serialization not supported.", fieldType.Name, com.GetType().Name, field.Name).ToString());
                //continue;
            }

            // if this MonoBehaviour refer to another MonoBehaviour (A)
            // A must be export or compiled to JavaScript as well
            if (typeof(MonoBehaviour).IsAssignableFrom(fieldType))
            {
                if (!JSSerializerEditor.WillTypeBeAvailableInJavaScript(fieldType))
                {
                    lstProblem.Add(new StringBuilder().AppendFormat("{0} {1}.{2} not available in JavaScript.", fieldType.Name, com.GetType().Name, field.Name).ToString());
                }
            }

            //more to exam
        }
        return lstProblem;
    }
开发者ID:benbon,项目名称:qjsbunitynew,代码行数:43,代码来源:JSAnalyzer.cs

示例9: Open

    public void Open(MonoBehaviour scriptToUse, string _dropdownMenu = null)
    {
        ClearButtons();
        script = scriptToUse;
        isOpen = true;

        if(_dropdownMenu == null){
            _dropdownMenu = scriptToUse.GetType().Name;
        }
        SetButtons(_dropdownMenu);

        if(UIManager.UICamera) {
            transform.position = UIManager.MainToUICameraPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition));
        } else {
            transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + Camera.main.transform.forward * 0.9f);
        }
    }
开发者ID:Jonanory,项目名称:Reputations,代码行数:17,代码来源:DropDownMenu.cs

示例10: PropertyCopier

        public PropertyCopier(MonoBehaviour pPrototype, System.Type pAttribute)
        {
            prototype = pPrototype;
            prototypeType = pPrototype.GetType();

            List<PropertyInfo> lOut = new List<PropertyInfo>();
            var lMembers =prototypeType.GetMembers();
            foreach (var lMember in lMembers)
            {
                var lAttributes =
                    lMember.GetCustomAttributes(pAttribute, false);
                if (lAttributes.Length > 0)
                {
                    lOut.Add((PropertyInfo)lMember);
                }
            }
            copyList = lOut.ToArray();
        }
开发者ID:Seraphli,项目名称:TheInsectersWar,代码行数:18,代码来源:zzCopyProperty.cs

示例11: EventResponseWrapper

 /// <summary>
 /// Creates a new instance of EventResponseWrapper, tying the given EventResponder to the specified Event.
 /// </summary>
 /// <param name="targetComponent">The MonoBehaviour that contains the event to which the EventResponder will be bound.</param>
 /// <param name="eventName">The string-name of the Event on the target MonoBehaviour.</param>
 /// <param name="responder">The EventResponder object that will be hooked into the specified event.</param>
 public EventResponseWrapper(MonoBehaviour targetComponent, string eventName, EventResponder responder)
 {
     this.targetComponentTypeName = targetComponent.GetType().Name;
     this.eventName = eventName;
     this.responder = responder;
 }
开发者ID:chrislewisdev,项目名称:Unity-Events-Editor,代码行数:12,代码来源:EventResponseWrapper.cs

示例12: ExportScript

 public void ExportScript(MonoBehaviour monoBehaviour)
 {
     Debug.Log("Start script export of " + monoBehaviour.GetType());
     assets.ExportScript(monoBehaviour.GetType(), false, true);
 }
开发者ID:Joelone,项目名称:FFWD,代码行数:5,代码来源:ExportSceneWizard.cs

示例13: SendMessage

 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 protected void SendMessage( MonoBehaviour _sender )
 {
     if ( receiver ) {
         receiver.SendMessage(action);
     }
     else
         Debug.LogWarning ( "No receiver of signal \"" + action
                            + "\" on object " + _sender.name
                            + " (" + _sender.GetType().Name + ")",
                            _sender );
 }
开发者ID:exdev,项目名称:ex-unity-old-deprecated,代码行数:14,代码来源:exSingalSender.cs

示例14: GetCachedMethod

    private MethodInfo GetCachedMethod(MonoBehaviour monob, PhotonNetworkingMessage methodType)
    {
        Type type = monob.GetType();
        if (!this.cachedMethods.ContainsKey(type))
        {
            Dictionary<PhotonNetworkingMessage, MethodInfo> newMethodsDict = new Dictionary<PhotonNetworkingMessage, MethodInfo>();
            this.cachedMethods.Add(type, newMethodsDict);
        }

        // Get method type list
        Dictionary<PhotonNetworkingMessage, MethodInfo> methods = this.cachedMethods[type];
        if (!methods.ContainsKey(methodType))
        {
            // Load into cache
            Type[] argTypes;
            if (methodType == PhotonNetworkingMessage.OnPhotonSerializeView)
            {
                argTypes = new Type[2];
                argTypes[0] = typeof(PhotonStream);
                argTypes[1] = typeof(PhotonMessageInfo);
            }
            else if (methodType == PhotonNetworkingMessage.OnPhotonInstantiate)
            {
                argTypes = new Type[1];
                argTypes[0] = typeof(PhotonMessageInfo);
            }
            else
            {
                Debug.LogError("Invalid PhotonNetworkingMessage!");
                return null;
            }

            MethodInfo metInfo = monob.GetType().GetMethod(methodType + string.Empty, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, argTypes, null);
            if (metInfo != null)
            {
                methods.Add(methodType, metInfo);
            }
        }

        if (methods.ContainsKey(methodType))
        {
            return methods[methodType];
        }
        else
        {
            return null;
        }
    }
开发者ID:rmkeezer,项目名称:fpsgame,代码行数:48,代码来源:NetworkingPeer.cs

示例15: CopyBehaviour

    static void CopyBehaviour(MonoBehaviour behaviour, JSSerializer serizlizer)
    {
        lstAnalyze.Clear();
        lstString.Clear();
        lstObjs.Clear();

        // GameObject go = behaviour.gameObject;
        //Type type = behaviour.GetType();

        FieldInfo[] fields = GetMonoBehaviourSerializedFields(behaviour);
        foreach (FieldInfo field in fields)
        {
            AddAnalyze(field.FieldType, field.Name, field.GetValue(behaviour));
        }

        TraverseAnalyze();

        for (var i = 0; i < lstAnalyze.Count; i++)
        {
            lstAnalyze[i].Alloc(serizlizer);
        }
        serizlizer.jsClassName = JSNameMgr.GetTypeFullName(behaviour.GetType());
        serizlizer.arrString = lstString.ToArray();
        serizlizer.arrObject = lstObjs.ToArray();
    }
开发者ID:shuidong,项目名称:qjsbunitynew,代码行数:25,代码来源:JSSerializerEditor.cs


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