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


C# NavGraph.GetNodes方法代码示例

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


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

示例1: DrawGraph


//.........这里部分代码省略.........
			}
			if (GUILayout.Button (new GUIContent ("Down","Decrease the graph priority"),GUILayout.Width (40))) {
				int index = script.astarData.GetGraphIndex (graph);
				
				//Find the next non null graph
				int next = index+1;
				for (;next<script.graphs.Length;next++) if (script.graphs[next] != null) break;
				
				if (next < script.graphs.Length) {
					NavGraph tmp = script.graphs[next];
					script.graphs[next] = graph;
					script.graphs[index] = tmp;
					
					GraphEditor tmpEditor = graphEditors[next];
					graphEditors[next] = graphEditors[index];
					graphEditors[index] = tmpEditor;
				}
				CheckGraphEditors ();
				Repaint ();
			}
		}
		
		bool drawGizmos = GUILayout.Toggle (graph.drawGizmos,"Draw Gizmos",graphGizmoButtonStyle);
		if (drawGizmos != graph.drawGizmos) {
			graph.drawGizmos = drawGizmos;
			RepaintSceneView ();
		}
		
		if (GUILayout.Toggle (graph.infoScreenOpen,"Info",graphInfoButtonStyle)) {
			if (!graph.infoScreenOpen) {
				graph.infoScreenOpen = true;
				graph.open = true;
			}
		} else {
			graph.infoScreenOpen = false;
		}
		
		if (GUILayout.Button ("Delete",graphDeleteButtonStyle)) {
			RemoveGraph (graph);
			return true;
		}
		GUILayout.EndHorizontal ();


		if (topFadeArea.Show () ) {
			EditorGUILayoutx.FadeArea fadeArea = GUILayoutx.BeginFadeArea (graph.infoScreenOpen,"graph_info_"+graph.guid,0);
			if (fadeArea.Show ()) {
				
				bool nodenull = false;
				int total = 0;
				int numWalkable = 0;

				KeyValuePair<float,KeyValuePair<int,int>> pair;
				if ( graphNodeCounts == null ) graphNodeCounts = new Dictionary<NavGraph, KeyValuePair<float, KeyValuePair<int, int>>>();

				if ( !graphNodeCounts.TryGetValue ( graph, out pair ) || (Time.realtimeSinceStartup-pair.Key) > 2 ) {
					GraphNodeDelegateCancelable counter = delegate (GraphNode node) {
						if (node == null) {
							nodenull = true;
							return true;
						}
						total++;
						if (node.Walkable) numWalkable++;
						return true;
					};
					graph.GetNodes (counter);
					pair = new KeyValuePair<float, KeyValuePair<int, int>> (Time.realtimeSinceStartup, new KeyValuePair<int,int>( total, numWalkable ) );
					graphNodeCounts[graph] = pair;
				}

				total = pair.Value.Key;
				numWalkable = pair.Value.Value;

			
				EditorGUI.indentLevel++;
				
				if (nodenull) {
					//EditorGUILayout.HelpBox ("Some nodes in the graph are null. Please report this error.", MessageType.Info);
					Debug.LogError ("Some nodes in the graph are null. Please report this error.");
				}
				
				EditorGUILayout.LabelField ("Nodes",total.ToString());
				EditorGUILayout.LabelField ("Walkable",numWalkable.ToString ());
				EditorGUILayout.LabelField ("Unwalkable",(total-numWalkable).ToString ());
				if (total == 0) EditorGUILayout.HelpBox ("The number of nodes in the graph is zero. The graph might not be scanned",MessageType.Info);
				
				EditorGUI.indentLevel--;
			}
			GUILayoutx.EndFadeArea ();
			
			GUI.color = tmp2;
			
			graphEditor.OnInspectorGUI (graph);
			graphEditor.OnBaseInspectorGUI (graph);
		}

		GUILayoutx.EndFadeArea ();
		
		return false;
	}
开发者ID:moderndelta137,项目名称:Shadow_Sword,代码行数:101,代码来源:AstarPathEditor.cs


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