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


C# Component.GetInstanceID方法代码示例

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


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

示例1: OnHealthChange

    //-------------------------------------------------------
    //Function called when health changes
    void OnHealthChange(Component Enemy, int NewHealth)
    {
        //If health has changed of this object
        if(this.GetInstanceID() != Enemy.GetInstanceID()) return;

        Debug.Log ("Object: " + gameObject.name +  " Health is: " + NewHealth.ToString());
    }
开发者ID:juanferfranco,项目名称:PDOO,代码行数:9,代码来源:EnemyObject.cs

示例2: OnManaChange

    void OnManaChange(Component Health, object newMana)
    {
        //If health has changed of this object
        if (this.GetInstanceID() != Health.GetInstanceID()) return;

        Debug.Log("Object: " + gameObject.name + "'s Mana is: " + newMana.ToString());
    }
开发者ID:cuongngo90,项目名称:Unity-Events,代码行数:7,代码来源:Health.cs

示例3: OnManaEmpty

    void OnManaEmpty(Component Health, object newMana)
    {
        if (_heath.GetInstanceID() != Health.GetInstanceID())
            return;

        Debug.Log("Object: " + gameObject.name + " is empty Mana: " + newMana.ToString());
    }
开发者ID:cuongngo90,项目名称:Unity-Events,代码行数:7,代码来源:Skill.cs

示例4: RemoveListener

    public void RemoveListener(Component game_object, string notification_name)
    {
        if (!listeners_dictionary.ContainsKey (notification_name))
            return;

        for (int i=listeners_dictionary[notification_name].Count-1; i>=0; i--) {
            if (listeners_dictionary[notification_name][i].GetInstanceID() == game_object.GetInstanceID())
                listeners_dictionary[notification_name].RemoveAt(i);
        }
    }
开发者ID:elgarat,项目名称:sci-fi-mem-tool,代码行数:10,代码来源:NotificationManager.cs

示例5: RemoveListener

    public void RemoveListener(Component Sender, string NotificationName)
    {
        if(!Listeners.ContainsKey(NotificationName))
            return;

        for(int i = Listeners[NotificationName].Count - 1; i >= 0; i--)
        {
            if(Listeners[NotificationName][i].GetInstanceID() == Sender.GetInstanceID ())
                Listeners[NotificationName].RemoveAt(i);
        }
    }
开发者ID:kaluluosi,项目名称:quad,代码行数:11,代码来源:NotificationCenter.cs

示例6: RemoveEvent

	public void RemoveEvent (Component sender, string notificationType)
	{
		if (!m_listeners.ContainsKey (notificationType))
			return;
		List<Component> listeners = m_listeners [notificationType];
		for (int i = listeners.Count - 1; i >= 0; i--) {
			if (listeners [i].GetInstanceID () == sender.GetInstanceID ())
				listeners.RemoveAt (i);
		}
		//m_listeners [notificationType].Remove (sender);
	}
开发者ID:PoH-TeamEEM,项目名称:PlaceOfHorror_EEM,代码行数:11,代码来源:EventManager.cs

示例7: RemoveListener

		//------------------------------------------------
		//Function to remove a listener for a notification
		public void RemoveListener (Component sender, string notificationType)
		{
				//If no key in dictionary exists, then exit
				if (!m_listeners.ContainsKey (notificationType))
						return;
				//Cycle through listeners and identify component, and then remove
				List<Component> listeners = m_listeners [notificationType];
				for (int i = listeners.Count - 1; i >= 0; i--) {
						if (listeners [i].GetInstanceID () == sender.GetInstanceID ())
								listeners.RemoveAt (i);
				}
		}
开发者ID:PoH-TeamEEM,项目名称:PlaceOfHorror_EEM,代码行数:14,代码来源:NotificationManager.cs

示例8: RemoveListener

    //------------------------------------------------
    //Function to remove a listener for a notification
    public void RemoveListener(Component Sender, string NotificationName)
    {
        //If no key in dictionary exists, then exit
        if(!Listeners.ContainsKey(NotificationName))
            return;

        //Cycle through listeners and identify component, and then remove
        for(int i = Listeners[NotificationName].Count-1; i>=0; i--)
        {
            //Check instance ID
            if(Listeners[NotificationName][i].GetInstanceID() == Sender.GetInstanceID())
                Listeners[NotificationName].RemoveAt(i); //Matched. Remove from list
        }
    }
开发者ID:patrickbraud,项目名称:GameDesignProject,代码行数:16,代码来源:NotificationsManager.cs

示例9: RemoveListener

    /// <summary>
    /// Removes the listener.
    /// </summary>
    /// <param name="_sender">Sender monobehaiviour.</param>
    /// <param name="_eventName">Event name.</param>
    public void RemoveListener(Component _sender, string _eventName)
    {
        // Check if current event exists
        if(!ListenerComponents.ContainsKey(_eventName))
            return;

        // Loop throw all register events
        for(int i = ListenerComponents[_eventName].Count-1; i >= 0; i--)
        {
                // Remove wanted event
            if(ListenerComponents[_eventName][i].ListenerObject.GetInstanceID () == _sender.GetInstanceID())
                ListenerComponents[_eventName].RemoveAt(i);
        }
    }
开发者ID:sgrozo1,项目名称:Juego_Escalera,代码行数:19,代码来源:EventManager.cs

示例10: ComponentField

    public static Component ComponentField( string label, Component value, Type componentType )
    {
        componentType = componentType ?? typeof( MonoBehaviour );

        EditorGUILayout.BeginHorizontal();
        {

            EditorGUILayout.LabelField( label, "", GUILayout.Width( dfEditorUtil.LabelWidth - 10 ) );

            GUILayout.Space( 5 );

            var displayText = value == null ? "[none]" : value.ToString();
            GUILayout.Label( displayText, "TextField", GUILayout.ExpandWidth( true ), GUILayout.MinWidth( 100 ) );

            var evt = Event.current;
            if( evt != null )
            {
                var textRect = GUILayoutUtility.GetLastRect();
                if( evt.type == EventType.mouseDown && evt.clickCount == 2 )
                {
                    if( textRect.Contains( evt.mousePosition ) )
                    {
                        if( GUI.enabled && value != null )
                        {
                            Selection.activeObject = value;
                            EditorGUIUtility.PingObject( value );
                            GUIUtility.hotControl = value.GetInstanceID();
                        }
                    }
                }
                else if( evt.type == EventType.DragUpdated || evt.type == EventType.DragPerform )
                {
                    if( textRect.Contains( evt.mousePosition ) )
                    {

                        var reference = DragAndDrop.objectReferences.First();
                        var draggedComponent = (Component)null;
                        if( reference is Transform )
                        {
                            draggedComponent = (Transform)reference;
                        }
                        else if( reference is GameObject )
                        {
                            draggedComponent =
                                ( (GameObject)reference )
                                .GetComponents( componentType )
                                .FirstOrDefault();
                        }
                        else if( reference is Component )
                        {
                            draggedComponent = reference as Component;
                            if( draggedComponent == null )
                            {
                                draggedComponent =
                                    ( (Component)reference )
                                    .GetComponents( componentType )
                                    .FirstOrDefault();
                            }
                        }

                        DragAndDrop.visualMode = ( draggedComponent == null ) ? DragAndDropVisualMode.None : DragAndDropVisualMode.Copy;

                        if( evt.type == EventType.DragPerform )
                        {
                            value = draggedComponent;
                        }

                        evt.Use();

                    }
                }
            }

            GUI.enabled = ( clipboard != null );
            {
                var tooltip = ( clipboard != null ) ? string.Format( "Paste {0} ({1})", clipboard.name, clipboard.GetType().Name ) : "";
                var content = new GUIContent( "Paste", tooltip );
                if( GUILayout.Button( content, "minibutton", GUILayout.Width( 50 ) ) )
                {
                    value = clipboard;
                }
            }
            GUI.enabled = true;

        }
        EditorGUILayout.EndHorizontal();

        GUILayout.Space( 3 );

        return value;
    }
开发者ID:BjarkeHou,项目名称:ProjectGuard,代码行数:91,代码来源:dfEditorUtil.cs

示例11: WeaponChange

    //------------------------------------------------
    //Weapon change event - called when player changes weapon
    public void WeaponChange(Component Sender)
    {
        //Has player changed to this weapon?
        if(Sender.GetInstanceID() == GetInstanceID()) return;

        //Has changed to other weapon. Hide this weapon
        StopAllCoroutines();
        gameObject.SendMessage("StopSpriteAnimation", 0, SendMessageOptions.DontRequireReceiver);

        //Deactivate equipped
        IsEquipped = false;

        foreach(SpriteRenderer SR in WeaponSprites)
            SR.enabled = false;
    }
开发者ID:patrickbraud,项目名称:GameDesignProject,代码行数:17,代码来源:Weapon_Punch.cs

示例12: ComponentField

	private Component ComponentField(string label, Component value, Type componentType = null)
	{
		componentType = componentType ?? typeof(MonoBehaviour);

		EditorGUILayout.BeginHorizontal();
		{
			EditorGUILayout.LabelField(label, "", GUILayout.Width(90));

			GUILayout.Space(5);

			var displayText = value == null ? "[none] - Drag Component Here" : value.ToString();
			GUILayout.Label(displayText, "TextField", GUILayout.ExpandWidth(true), GUILayout.MinWidth(100));

			var evt = Event.current;
			if(evt != null)
			{
				var textRect = GUILayoutUtility.GetLastRect();
				if(evt.type == EventType.mouseDown && evt.clickCount == 2)
				{
					if(textRect.Contains(evt.mousePosition))
					{
						if(GUI.enabled && value != null)
						{
							Selection.activeObject = value;
							EditorGUIUtility.PingObject( value );
							GUIUtility.hotControl = value.GetInstanceID();
						}
					}
				}
				else if(evt.type == EventType.DragUpdated || evt.type == EventType.DragPerform)
				{
					if(textRect.Contains(evt.mousePosition))
					{

						var reference = DragAndDrop.objectReferences.First();
						var draggedComponent = (Component)null;
						if(reference is Transform)
						{
							draggedComponent = (Transform)reference;
						}
						else if(reference is GameObject)
						{
							draggedComponent =
								( (GameObject)reference )
								.GetComponents( componentType )
								.FirstOrDefault();
						}
						else if(reference is Component)
						{
							draggedComponent = reference as Component;
							if(draggedComponent == null)
							{
								draggedComponent =
									((Component)reference)
									.GetComponents(componentType)
									.FirstOrDefault();
							}
						}

						DragAndDrop.visualMode = (draggedComponent == null) ? DragAndDropVisualMode.None : DragAndDropVisualMode.Copy;

						if(evt.type == EventType.DragPerform)
						{
							value = draggedComponent;
						}
						
						evt.Use();
					}
				}
			}
		}
		EditorGUILayout.EndHorizontal();

		GUILayout.Space(3);

		return value;
	}
开发者ID:Wuzseen,项目名称:Circuit-Math,代码行数:77,代码来源:AudioSourceProEditor.cs


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