本文整理汇总了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());
}
示例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());
}
示例3: OnManaEmpty
void OnManaEmpty(Component Health, object newMana)
{
if (_heath.GetInstanceID() != Health.GetInstanceID())
return;
Debug.Log("Object: " + gameObject.name + " is empty Mana: " + newMana.ToString());
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}