當前位置: 首頁>>代碼示例>>C#>>正文


C# Pathfinding.NavGraph類代碼示例

本文整理匯總了C#中Pathfinding.NavGraph的典型用法代碼示例。如果您正苦於以下問題:C# NavGraph類的具體用法?C# NavGraph怎麽用?C# NavGraph使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NavGraph類屬於Pathfinding命名空間,在下文中一共展示了NavGraph類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnInspectorGUI

		//public GameObject meshRenderer;
		
		public override void OnInspectorGUI (NavGraph target) {
			NavMeshGraph graph = target as NavMeshGraph;
	/*
	#if UNITY_3_3
			graph.sourceMesh = EditorGUILayout.ObjectField ("Source Mesh",graph.sourceMesh,typeof(Mesh)) as Mesh;
	#else
			graph.sourceMesh = EditorGUILayout.ObjectField ("Source Mesh",graph.sourceMesh,typeof(Mesh), true) as Mesh;
	#endif
	*/
			graph.sourceMesh = ObjectField ("Source Mesh", graph.sourceMesh, typeof(Mesh), false) as Mesh;
	
	#if UNITY_LE_4_3
			EditorGUIUtility.LookLikeControls ();
			EditorGUILayoutx.BeginIndent ();
	#endif
			graph.offset = EditorGUILayout.Vector3Field ("Offset",graph.offset);
	
	#if UNITY_LE_4_3
			EditorGUILayoutx.EndIndent ();
			
			EditorGUILayoutx.BeginIndent ();
	#endif
			graph.rotation = EditorGUILayout.Vector3Field ("Rotation",graph.rotation);
	
	#if UNITY_LE_4_3
			EditorGUILayoutx.EndIndent ();
			EditorGUIUtility.LookLikeInspector ();
	#endif
	
			graph.scale = EditorGUILayout.FloatField (new GUIContent ("Scale","Scale of the mesh"),graph.scale);
			graph.scale = (graph.scale < 0.01F && graph.scale > -0.01F) ? (graph.scale >= 0 ? 0.01F : -0.01F) : graph.scale;
			
			graph.accurateNearestNode = EditorGUILayout.Toggle (new GUIContent ("Accurate Nearest Node Queries","More accurate nearest node queries. See docs for more info"),graph.accurateNearestNode);
		}
開發者ID:henryj41043,項目名稱:TheUnseen,代碼行數:36,代碼來源:NavMeshGeneratorEditor.cs

示例2: OnSceneGUI

		public override void OnSceneGUI (NavGraph target) {
			
			//NavMeshGraph graph = target as NavMeshGraph;
			
			/*if (meshRenderer == null) {
				Debug.Log ("IsNull");
				meshRenderer = new GameObject ("NavmeshRenderer");
				meshRenderer.hideFlags = HideFlags.HideAndDontSave;
				
				Renderer renderer = meshRenderer.AddComponent (typeof(MeshRenderer)) as Renderer;
				MeshFilter filter = meshRenderer.AddComponent (typeof(MeshFilter)) as MeshFilter;
				
				Mesh mesh = new Mesh ();
				mesh.vertices = graph.vertices;
				mesh.triangles = graph.triangles;
				
				mesh.RecalculateBounds ();
				mesh.RecalculateNormals ();
				
				filter.mesh = mesh;
				
				renderer.material = new Material (Shader.Find ("Transparent/Diffuse"));
				renderer.material.color = AstarColor.MeshColor;
			} else {
				Debug.Log ("Not Null "+meshRenderer.renderer.enabled+" "+meshRenderer.hideFlags);
				//meshRenderer.transform.position = new Vector3 (0,5,0);//meshRenderer.transform.position+Vector3.up*0.5F;
				meshRenderer.active = false;
				meshRenderer.active = true;
				
				
			}*/
			
			//DrawAALine (Vector3.zero,Vector3.one*20);
		}
開發者ID:henryj41043,項目名稱:TheUnseen,代碼行數:34,代碼來源:NavMeshGeneratorEditor.cs

示例3: ScanGraph

        public static void ScanGraph(NavGraph graph)
        {
            if (AstarPath.OnGraphPreScan != null) {
            AstarPath.OnGraphPreScan (graph);
            }

            graph.Scan ();

            int index = AstarPath.active.astarData.GetGraphIndex (graph);
            if (index < 0) throw new System.ArgumentException ("Graph is not added to AstarData");

            if (graph.nodes != null) {
            for (int j=0;j<graph.nodes.Length;j++) {
                if (graph.nodes[j] != null)
                    graph.nodes[j].graphIndex = index;
            }
            }

            if (AstarPath.OnGraphPostScan != null) {
            AstarPath.OnGraphPostScan (graph);
            }

            AstarPath.active.FloodFill ();

            AstarPath.active.DataUpdate ();
        }
開發者ID:kiriri,項目名稱:playmaker-astar-actions,代碼行數:26,代碼來源:AstarPathExtension.cs

示例4: OnInspectorGUI

		public override void OnInspectorGUI (NavGraph target) {
			var graph = target as LayerGridGraph;

			base.OnInspectorGUI(target);

			if (graph.neighbours != NumNeighbours.Four) {
				Debug.Log("Note: Only 4 neighbours per grid node is allowed in this graph type");
			}
		}
開發者ID:Alx666,項目名稱:ProjectPhoenix,代碼行數:9,代碼來源:LayerGridGraphEditor.cs

示例5: OnInspectorGUI

		public override void OnInspectorGUI (NavGraph target) {
			var graph = target as NavMeshGraph;

			graph.sourceMesh = ObjectField ("Source Mesh", graph.sourceMesh, typeof(Mesh), false) as Mesh;

			graph.offset = EditorGUILayout.Vector3Field ("Offset",graph.offset);

			graph.rotation = EditorGUILayout.Vector3Field ("Rotation",graph.rotation);

			graph.scale = EditorGUILayout.FloatField (new GUIContent ("Scale","Scale of the mesh"),graph.scale);
			graph.scale = (graph.scale < 0.01F && graph.scale > -0.01F) ? (graph.scale >= 0 ? 0.01F : -0.01F) : graph.scale;

			graph.accurateNearestNode = EditorGUILayout.Toggle (new GUIContent ("Accurate Nearest Node Queries","More accurate nearest node queries. See docs for more info"),graph.accurateNearestNode);
		}
開發者ID:smclallen,項目名稱:Galactic_Parcel_Service,代碼行數:14,代碼來源:NavMeshGeneratorEditor.cs

示例6: OnEnter

        public override void OnEnter()
        {
            var mo = graph.Value as FsmNavGraph;
            if(mo.Value == null)
            {
                Finish();
                return;
            } // it would continue for a frame without return

            g = FsmConverter.GetNavGraph(graph);

            DoStuff();

            if (!everyFrame.Value)
            { Finish(); }
        }
開發者ID:kiriri,項目名稱:playmaker-astar-actions,代碼行數:16,代碼來源:createNodes.cs

示例7: OnInspectorGUI

        public override void OnInspectorGUI(NavGraph target)
        {
            var graph = target as PointGraph;

            graph.root = ObjectField (new GUIContent ("Root","All childs of this object will be used as nodes, if it is not set, a tag search will be used instead (see below)"),graph.root,typeof(Transform),true) as Transform;

            graph.recursive = EditorGUILayout.Toggle (new GUIContent ("Recursive","Should childs of the childs in the root GameObject be searched"),graph.recursive);
            graph.searchTag = EditorGUILayout.TagField (new GUIContent ("Tag","If root is not set, all objects with this tag will be used as nodes"),graph.searchTag);

            if (graph.root != null) {
                EditorGUILayout.HelpBox ("All childs "+(graph.recursive ? "and sub-childs ":"") +"of 'root' will be used as nodes\nSet root to null to use a tag search instead", MessageType.None);
            } else {
                EditorGUILayout.HelpBox ("All object with the tag '"+graph.searchTag+"' will be used as nodes"+(graph.searchTag == "Untagged" ? "\nNote: the tag 'Untagged' cannot be used" : ""), MessageType.None);
            }

            graph.maxDistance = EditorGUILayout.FloatField (new GUIContent ("Max Distance","The max distance in world space for a connection to be valid. A zero counts as infinity"),graph.maxDistance);

            graph.limits = EditorGUILayout.Vector3Field ("Max Distance (axis aligned)",graph.limits);

            graph.raycast = EditorGUILayout.Toggle (new GUIContent ("Raycast","Use raycasting to check if connections are valid between each pair of nodes"),graph.raycast);

            if ( graph.raycast ) {
                EditorGUI.indentLevel++;

                graph.use2DPhysics = EditorGUILayout.Toggle (new GUIContent ("Use 2D Physics", "If enabled, all raycasts will use the Unity 2D Physics API instead of the 3D one."), graph.use2DPhysics);
             	graph.thickRaycast = EditorGUILayout.Toggle (new GUIContent ("Thick Raycast","A thick raycast checks along a thick line with radius instead of just along a line"),graph.thickRaycast);

                if ( graph.thickRaycast ) {
                    EditorGUI.indentLevel++;
             		graph.thickRaycastRadius = EditorGUILayout.FloatField (new GUIContent ("Raycast Radius","The radius in world units for the thick raycast"),graph.thickRaycastRadius);
             		EditorGUI.indentLevel--;
                }

                graph.mask = EditorGUILayoutx.LayerMaskField ("Mask",graph.mask);
                EditorGUI.indentLevel--;
            }

            graph.optimizeForSparseGraph = EditorGUILayout.Toggle (new GUIContent ("Optimize For Sparse Graph","Check online documentation for more information."),graph.optimizeForSparseGraph);

            if ( graph.optimizeForSparseGraph ) {
                EditorGUI.indentLevel++;

                graph.optimizeFor2D = EditorGUILayout.Toggle (new GUIContent ("Optimize For XZ Plane","Check online documentation for more information."),graph.optimizeFor2D);

                EditorGUI.indentLevel--;
            }
        }
開發者ID:jgirald,項目名稱:ES2015F,代碼行數:47,代碼來源:PointGeneratorEditor.cs

示例8: OnInspectorGUI

		public override void OnInspectorGUI (NavGraph target) {
			var graph = target as GridGraph;

			DrawFirstSection(graph);
			Separator();
			DrawMiddleSection(graph);
			Separator();
			DrawCollisionEditor(graph.collision);

			if (graph.collision.use2D) {
				if (Mathf.Abs(Vector3.Dot(Vector3.forward, Quaternion.Euler(graph.rotation) * Vector3.up)) < 0.9f) {
					EditorGUILayout.HelpBox("When using 2D it is recommended to rotate the graph so that it aligns with the 2D plane.", MessageType.Warning);
				}
			}

			Separator();
			DrawLastSection(graph);
		}
開發者ID:Alx666,項目名稱:ProjectPhoenix,代碼行數:18,代碼來源:GridGeneratorEditor.cs

示例9: OnInspectorGUI

		public override void OnInspectorGUI (NavGraph target) {
			
			LayerGridGraph graph = target as LayerGridGraph;
			
			graph.mergeSpanRange = EditorGUILayout.FloatField ("Merge Span Range",graph.mergeSpanRange);
			graph.characterHeight = EditorGUILayout.FloatField ("Character Height",graph.characterHeight);
			graph.maxClimb = Mathf.Clamp (EditorGUILayout.FloatField ("Max climb",graph.maxClimb),0,graph.characterHeight);
			
			graph.neighbours = NumNeighbours.Four;
			textureVisible = false;
			base.OnInspectorGUI (target);
			
			if (graph.neighbours != NumNeighbours.Four) {
				Debug.Log ("Note: Only 4 neighbours per grid node is allowed in this graph type");
			}
			
			if (graph.collision.thickRaycast)
				HelpBox ("Note: Thick raycast cannot be used with this graph type");
		}
開發者ID:Gapti,項目名稱:ClashOfClanRIP,代碼行數:19,代碼來源:LayerGridGraphEditor.cs

示例10: GetNode

		/** Returns the node at \a graphs[graphIndex].nodes[nodeIndex]. The graphIndex refers to the specified graphs array.\n
		 * All kinds of error checking is done to make sure no exceptions are thrown */
		public GraphNode GetNode (int graphIndex, int nodeIndex, NavGraph[] graphs) {
			throw new System.NotImplementedException ();
			
			/*
			if (graphs == null) {
				return null;
			}
			
			if (graphIndex < 0 || graphIndex >= graphs.Length) {
				Debug.LogError ("Graph index is out of range"+graphIndex+ " [0-"+(graphs.Length-1)+"]");
				return null;
			}
			
			NavGraph graph = graphs[graphIndex];
			
			if (graph.nodes == null) {
				return null;
			}
			
			if (nodeIndex < 0 || nodeIndex >= graph.nodes.Length) {
				Debug.LogError ("Node index is out of range : "+nodeIndex+ " [0-"+(graph.nodes.Length-1)+"]"+" (graph "+graphIndex+")");
				return null;
			}
			
			return graph.nodes[nodeIndex];*/
		}
開發者ID:henryj41043,項目名稱:TheUnseen,代碼行數:28,代碼來源:AstarData.cs

示例11: RemoveGraph

		/** Removes the specified graph from the #graphs array and Destroys it in a safe manner.
		 * To avoid changing graph indices for the other graphs, the graph is simply nulled in the array instead
		 * of actually removing it from the array.
		 * The empty position will be reused if a new graph is added.
		 * 
		 * \returns True if the graph was sucessfully removed (i.e it did exist in the #graphs array). False otherwise.
		 * 
		 * \see NavGraph.SafeOnDestroy
		 * 
		 * \version Changed in 3.2.5 to call SafeOnDestroy before removing
		 * and nulling it in the array instead of removing the element completely in the #graphs array.
		 * 
		 */
		public bool RemoveGraph (NavGraph graph) {
			
			//Safe OnDestroy is called since there is a risk that the pathfinding is searching through the graph right now,
			//and if we don't wait until the search has completed we could end up with evil NullReferenceExceptions
			graph.SafeOnDestroy ();
			
			int i=0;
			for (;i<graphs.Length;i++) if (graphs[i] == graph) break;
			if (i == graphs.Length) {
				return false;
			}
			
			graphs[i] = null;
			
			UpdateShortcuts ();
			
			return true;
		}
開發者ID:henryj41043,項目名稱:TheUnseen,代碼行數:31,代碼來源:AstarData.cs

示例12: Serialize

        /** Serializes the graph settings to JSON and returns the data */
        public byte[] Serialize(NavGraph graph)
        {
            System.Text.StringBuilder output = GetStringBuilder ();//new System.Text.StringBuilder();
            JsonWriter writer = new JsonWriter (output,writerSettings);
            writer.Write (graph);

            return encoding.GetBytes (output.ToString());
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:9,代碼來源:JsonSerializer.cs

示例13: DeSerializeSettings

        //This is intended for quick saving of settings for e.g Undo operations
        public void DeSerializeSettings(NavGraph graph, AstarPath active)
        {
            ISerializableGraph serializeGraph = graph as ISerializableGraph;

            if (serializeGraph == null) {
                Debug.LogError ("The graph specified is not (de)serializable (how it could be serialized in the first place is a mystery) the graph was of type "+graph.GetType());
                return;
            }

            graph.open = readerStream.ReadBoolean ();

            //readerStream.ReadString ();
            serializeGraph.DeSerializeSettings (this);
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:15,代碼來源:AstarSerialize.cs

示例14: DeSerializeEditorSettings

        public void DeSerializeEditorSettings(NavGraph graph, ISerializableGraphEditor editor, AstarPath active)
        {
            if (editor == null) {
                Debug.LogError ("The editor specified is Null");
                return;
            }

            editor.DeSerializeSettings (graph,this);
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:9,代碼來源:AstarSerialize.cs

示例15: SetUpGraphRefs

        public void SetUpGraphRefs(NavGraph[] graphs)
        {
            graphRefGuids = new int[loadedGraphGuids.Length];

            for (int i=0;i<loadedGraphGuids.Length;i++) {

                Pathfinding.Util.Guid guid = new Pathfinding.Util.Guid (loadedGraphGuids[i]);

                graphRefGuids[i] = -1;

                for (int j=0;j<graphs.Length;j++) {
                    if (graphs[j].guid == guid) {
                        graphRefGuids[i] = i;
                    }
                }
                //graphRefGuids[i] = astarData.GuidToIndex ());
            }
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:18,代碼來源:AstarSerialize.cs


注:本文中的Pathfinding.NavGraph類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。