本文整理汇总了C#中NavGraph类的典型用法代码示例。如果您正苦于以下问题:C# NavGraph类的具体用法?C# NavGraph怎么用?C# NavGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NavGraph类属于命名空间,在下文中一共展示了NavGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInspectorGUI
public override void OnInspectorGUI(NavGraph target) {
MyAStarPointGraph graph = target as MyAStarPointGraph;
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);
EditorGUILayoutx.BeginIndent();
graph.limits = EditorGUILayout.Vector3Field("Max Distance (axis aligned)", graph.limits);
EditorGUILayoutx.EndIndent();
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.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) {
graph.thickRaycastRadius = EditorGUILayout.FloatField(new GUIContent("Raycast Radius", "The radius in world units for the thick raycast"), graph.thickRaycastRadius);
}
graph.mask = EditorGUILayoutx.LayerMaskField(/*new GUIContent (*/"Mask"/*,"Used to mask which layers should be checked")*/, graph.mask);
EditorGUI.indentLevel--;
}
}
示例2: 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;
EditorGUIUtility.LookLikeControls ();
EditorGUILayoutx.BeginIndent ();
graph.offset = EditorGUILayout.Vector3Field ("Offset",graph.offset);
EditorGUILayoutx.EndIndent ();
EditorGUILayoutx.BeginIndent ();
graph.rotation = EditorGUILayout.Vector3Field ("Rotation",graph.rotation);
EditorGUILayoutx.EndIndent ();
EditorGUIUtility.LookLikeInspector ();
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);
}
示例3: 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);
}
示例4: ExportToFile
/** Exports the INavmesh graph to a file */
public void ExportToFile(NavGraph target)
{
INavmesh graph = (INavmesh)target;
if (graph == null) return;
Int3[] vertices = graph.vertices;
if (vertices == null || target.nodes == null) {
if (EditorUtility.DisplayDialog ("Scan graph before exporting?","The graph does not contain any mesh data. Do you want to scan it?","Ok","Cancel")) {
AstarPath.MenuScan ();
} else {
return;
}
}
vertices = graph.vertices;
if (vertices == null || target.nodes == null) {
Debug.LogError ("Graph still does not contain any nodes or vertices. Canceling");
return;
}
string path = EditorUtility.SaveFilePanel ("Export .obj","","navmesh.obj","obj");
if (path == "") return;
//Generate .obj
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string name = System.IO.Path.GetFileNameWithoutExtension (path);
sb.Append ("g ").Append(name).AppendLine();
//Write vertices
for (int i=0;i<vertices.Length;i++) {
Vector3 v = (Vector3)vertices[i];
sb.Append(string.Format("v {0} {1} {2}\n",-v.x,v.y,v.z));
}
//Define single texture coordinate to zero
sb.Append ("vt 0\n");
//Write triangles
for (int i=0;i<target.nodes.Length;i++) {
MeshNode node = target.nodes[i] as MeshNode;
if (node == null) {
Debug.LogError ("Node could not be casted to MeshNode. Node was null or no MeshNode");
return;
}
sb.Append(string.Format("f {0}/0 {1}/0 {2}/0\n", node.v1+1,node.v2+1,node.v3+1));
}
string obj = sb.ToString();
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path))
{
sw.Write(obj);
}
}
示例5: h_func
protected override float h_func(ref NavGraph para_graph, ref NavNode para_nodeID, ref NavNode para_goalNodeID)
{
WorldNode wN1 = (WorldNode) para_nodeID;
WorldNode wN2 = (WorldNode) para_goalNodeID;
float retHVal = UnityEngine.Vector3.Distance(wN1.getWorldPt(),wN2.getWorldPt());
return retHVal;
}
示例6: ImgNavToWorldNavGraphBuilder
//NavGraph imgNavGraph;
//GridProperties gPropImgNav;
//GridProperties gPropWorldNav;
public ImgNavToWorldNavGraphBuilder(ref NavGraph para_imgNavGraph,
ref GridProperties para_gPropImgNavGraph,
ref GridProperties para_gPropWorldNavGraph)
{
//imgNavGraph = para_imgNavGraph;
//gPropImgNav = para_gPropImgNavGraph;
//gPropWorldNav = para_gPropWorldNavGraph;
}
示例7: OnInspectorGUI
public override void OnInspectorGUI(NavGraph target)
{
PointGraph graph = target as PointGraph;
/*
#if UNITY_3_3
graph.root = (Transform)EditorGUILayout.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));
#else
graph.root = (Transform)EditorGUILayout.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);
#endif
*/
//Debug.Log (EditorGUI.indentLevel);
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) {
GUILayout.Label ("All childs "+(graph.recursive ? "and sub-childs ":"") +"of 'root' will be used as nodes\nSet root to null to use a tag search instead",AstarPathEditor.helpBox);
} else {
GUILayout.Label ("All object with the tag '"+graph.searchTag+"' will be used as nodes"+(graph.searchTag == "Untagged" ? "\nNote: the tag 'Untagged' cannot be used" : ""),AstarPathEditor.helpBox);
}
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);
EditorGUIUtility.LookLikeControls ();
#if UNITY_4_0
graph.limits = EditorGUILayout.Vector3Field ("Max Distance (axis aligned)",graph.limits);
#else
EditorGUILayoutx.BeginIndent ();
graph.limits = EditorGUILayout.Vector3Field ("Max Distance (axis aligned)",graph.limits);
EditorGUILayoutx.EndIndent ();
#endif
EditorGUIUtility.LookLikeInspector ();
graph.raycast = EditorGUILayout.Toggle (new GUIContent ("Raycast","Use raycasting to check if connections are valid between each pair of nodes"),graph.raycast);
editor.GUILayoutx.BeginFadeArea (graph.raycast,"raycast");
EditorGUI.indentLevel++;
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);
editor.GUILayoutx.BeginFadeArea (graph.thickRaycast,"thickRaycast");
graph.thickRaycastRadius = EditorGUILayout.FloatField (new GUIContent ("Raycast Radius","The radius in world units for the thick raycast"),graph.thickRaycastRadius);
editor.GUILayoutx.EndFadeArea ();
//graph.mask = 1 << EditorGUILayout.LayerField ("Mask",(int)Mathf.Log (graph.mask,2));
graph.mask = EditorGUILayoutx.LayerMaskField (/*new GUIContent (*/"Mask"/*,"Used to mask which layers should be checked")*/,graph.mask);
EditorGUI.indentLevel--;
editor.GUILayoutx.EndFadeArea ();
}
示例8: OnInspectorGUI
public override void OnInspectorGUI(NavGraph target)
{
base.OnInspectorGUI(target);
Separator();
MyGridGraph graph = target as MyGridGraph;
GUILayout.BeginHorizontal();
graph.levelLayerMask = EditorGUILayoutx.LayerMaskField("Level Layers", graph.levelLayerMask);
GUILayout.EndHorizontal();
}
示例9: Graph_SearchDijkstra
public Graph_SearchDijkstra(NavGraph navGraph,
int sourceNodeID,
int targetNodeID = -1)
{
navGraph_ = navGraph;
shortestPathTree_ = new NavGraphEdge[navGraph.NumNodes()];
searchFrontier_ = new NavGraphEdge[navGraph.NumNodes()];
costToThisNode_ = new float[navGraph.NumNodes()];
sourceNodeID_ = sourceNodeID;
targetNodeID_ = targetNodeID;
Search();
}
示例10: SerializeSettings
public void SerializeSettings (NavGraph target, AstarSerializer serializer) {
//NavMeshGraph graph = target as NavMeshGraph;
//string meshPath = AssetDatabase.GetAssetPath (graph.sourceMesh);
//string meshGUID = AssetDatabase.AssetPathToGUID (meshPath);
/*if (graph == null) {
serializer.writerStream.Write (-1);
} else {
int instanceID = graph.sourceMesh != null ? graph.sourceMesh.GetInstanceID () : -1;
serializer.writerStream.Write (instanceID);
}*/
}
示例11: g_func
protected override float g_func(ref NavGraph para_graph, ref NavNode para_node1, ref NavNode para_node2)
{
NavEdge reqEdge = para_graph.getEdge(para_node1.getNodeID(),para_node2.getNodeID());
float retGVal = 0;
if(reqEdge == null)
{
retGVal = float.PositiveInfinity;
}
else
{
retGVal = reqEdge.getCost();
}
return retGVal;
}
示例12: 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;
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;
}
示例13: DeSerializeSettings
public void DeSerializeSettings (NavGraph target, AstarSerializer serializer) {
//NavMeshGraph graph = target as NavMeshGraph;
//string meshGUID = serializer.readerStream.ReadString ();
//int instanceID = serializer.readerStream.ReadInt32 ();
//Mesh ob = EditorUtility.InstanceIDToObject (instanceID) as Mesh;
//if (!Application.isPlaying) {
//graph.sourceMesh = ob;
/*string meshPath = AssetDatabase.GUIDToAssetPath (meshGUID);
Debug.Log (meshGUID +" "+ meshPath);
graph.sourceMesh = AssetDatabase.LoadAssetAtPath (meshPath,typeof(Mesh)) as Mesh;*/
//}
//Debug.Log ("Did succeed? "+(graph.sourceMesh != null));
}
示例14: Graph_SearchAStar_TS
public Graph_SearchAStar_TS(NavGraph graph, int source, int target)
: base(SearchType.AStar)
{
graph_ = graph;
shortestPathTree_ = new NavGraphEdge[graph.NumNodes()];
searchFrontier_ = new NavGraphEdge[graph.NumNodes()];
gCosts_ = new float[graph.NumNodes()];
fCosts_ = new float[graph.NumNodes()];
sourceIdx_ = source;
targetIdx_ = target;
//create the PQ
pq_ = new IndexedPriorityQLow(fCosts_, graph_.NumNodes());
//put the source node on the queue
pq_.Insert(sourceIdx_);
}
示例15: Graph_SearchDijkstras_TS
public Graph_SearchDijkstras_TS( NavGraph navGraph,
int sourceNodeIndex,
int targetNodeIndex)
: base(Graph_SearchTimeSliced.SearchType.Dijkstra)
{
navGraph_ = navGraph;
shortestPathTree_ = new NavGraphEdge[navGraph_.NumNodes()];
searchFrontier_ = new NavGraphEdge[navGraph_.NumNodes()];
costToThisNode_ = new float[navGraph_.NumNodes()];
sourceNodeIndex_ = sourceNodeIndex;
targetNodeIndex_ = targetNodeIndex;
//create the PQ ,
pq_ = new IndexedPriorityQLow( costToThisNode_, navGraph_.NumNodes() );
//put the source node on the queue
pq_.Insert( sourceNodeIndex_ );
}