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


C# EventDelegate.Clear方法代码示例

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


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

示例1: Field

	/// <summary>
	/// Draw an editor field for the Unity Delegate.
	/// </summary>

	static public bool Field (Object undoObject, EventDelegate del, bool removeButton)
	{
		if (del == null) return false;
		bool prev = GUI.changed;
		GUI.changed = false;
		bool retVal = false;
		MonoBehaviour target = del.target;
		bool remove = false;

		if (removeButton && (del.target != null || del.isValid))
		{
			if (del.target == null && del.isValid)
			{
				EditorGUILayout.LabelField("Notify", del.ToString());
			}
			else
			{
				target = EditorGUILayout.ObjectField("Notify", del.target, typeof(MonoBehaviour), true) as MonoBehaviour;
			}

			GUILayout.Space(-20f);
			GUILayout.BeginHorizontal();
			GUILayout.Space(64f);

#if UNITY_3_5
			if (GUILayout.Button("X", GUILayout.Width(20f)))
#else
			if (GUILayout.Button("", "ToggleMixed", GUILayout.Width(20f)))
#endif
			{
				target = null;
				remove = true;
			}
			GUILayout.EndHorizontal();
		}
		else
		{
			target = EditorGUILayout.ObjectField("Notify", del.target, typeof(MonoBehaviour), true) as MonoBehaviour;
		}

		if (remove)
		{
			NGUIEditorTools.RegisterUndo("Delegate Selection", undoObject);
			del.Clear();
			EditorUtility.SetDirty(undoObject);
		}
		else if (del.target != target)
		{
			NGUIEditorTools.RegisterUndo("Delegate Selection", undoObject);
			del.target = target;
			EditorUtility.SetDirty(undoObject);
		}

		if (del.target != null && del.target.gameObject != null)
		{
			GameObject go = del.target.gameObject;
			List<Entry> list = GetMethods(go);

			int index = 0;
			string[] names = GetMethodNames(list, del.ToString(), out index);
			int choice = 0;

			GUILayout.BeginHorizontal();
			choice = EditorGUILayout.Popup("Method", index, names);
			GUILayout.Space(18f);
			GUILayout.EndHorizontal();

			if (choice > 0)
			{
				if (choice != index)
				{
					Entry entry = list[choice - 1];
					NGUIEditorTools.RegisterUndo("Delegate Selection", undoObject);
					del.target = entry.target;
					del.methodName = entry.method.Name;
					EditorUtility.SetDirty(undoObject);
					GUI.changed = prev;
					return true;
				}
			}
		}

		retVal = GUI.changed;
		GUI.changed = prev;
		return retVal;
	}
开发者ID:CryptArc,项目名称:UnitySlots,代码行数:90,代码来源:EventDelegateEditor.cs

示例2: Field

	/// <summary>
	/// Draw an editor field for the Unity Delegate.
	/// </summary>

	static public bool Field (Object undoObject, EventDelegate del, bool removeButton, bool minimalistic)
	{
		if (del == null) return false;
		bool prev = GUI.changed;
		GUI.changed = false;
		bool retVal = false;
		MonoBehaviour target = del.target;
		bool remove = false;

		if (removeButton && (del.target != null || del.isValid))
		{
			if (!minimalistic) NGUIEditorTools.SetLabelWidth(82f);

			if (del.target == null && del.isValid)
			{
				EditorGUILayout.LabelField("Notify", del.ToString());
			}
			else
			{
				target = EditorGUILayout.ObjectField("Notify", del.target, typeof(MonoBehaviour), true) as MonoBehaviour;
			}

			GUILayout.Space(-18f);
			GUILayout.BeginHorizontal();
			GUILayout.Space(70f);

			if (GUILayout.Button("", "ToggleMixed", GUILayout.Width(20f), GUILayout.Height(16f)))
			{
				target = null;
				remove = true;
			}
			GUILayout.EndHorizontal();
		}
		else target = EditorGUILayout.ObjectField("Notify", del.target, typeof(MonoBehaviour), true) as MonoBehaviour;

		if (remove)
		{
			NGUIEditorTools.RegisterUndo("Delegate Selection", undoObject);
			del.Clear();
			EditorUtility.SetDirty(undoObject);
		}
		else if (del.target != target)
		{
			NGUIEditorTools.RegisterUndo("Delegate Selection", undoObject);
			del.target = target;
			EditorUtility.SetDirty(undoObject);
		}

		if (del.target != null && del.target.gameObject != null)
		{
			GameObject go = del.target.gameObject;
			List<Entry> list = GetMethods(go);

			int index = 0;
			string[] names = PropertyReferenceDrawer.GetNames(list, del.ToString(), out index);
			int choice = 0;

			GUILayout.BeginHorizontal();
			choice = EditorGUILayout.Popup("Method", index, names);
			NGUIEditorTools.DrawPadding();
			GUILayout.EndHorizontal();

			if (choice > 0 && choice != index)
			{
				Entry entry = list[choice - 1];
				NGUIEditorTools.RegisterUndo("Delegate Selection", undoObject);
				del.target = entry.target as MonoBehaviour;
				del.methodName = entry.name;
				EditorUtility.SetDirty(undoObject);
				retVal = true;
			}

			GUI.changed = false;
			EventDelegate.Parameter[] ps = del.parameters;

			if (ps != null)
			{
				for (int i = 0; i < ps.Length; ++i)
				{
					EventDelegate.Parameter param = ps[i];
					Object obj = EditorGUILayout.ObjectField("   Arg " + i, param.obj, typeof(Object), true);

					if (GUI.changed)
					{
						GUI.changed = false;
						param.obj = obj;
						EditorUtility.SetDirty(undoObject);
					}

					if (obj == null) continue;

					GameObject selGO = null;
					System.Type type = obj.GetType();
					if (type == typeof(GameObject)) selGO = obj as GameObject;
					else if (type.IsSubclassOf(typeof(Component))) selGO = (obj as Component).gameObject;

//.........这里部分代码省略.........
开发者ID:hanbim520,项目名称:UFLua,代码行数:101,代码来源:EventDelegateEditor.cs


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