/** Draws settings for using a texture as source for a grid. * \astarpro */ public void DrawTextureData(GridGraph.TextureData data, GridGraph graph) { if (data == null) { return; } data.enabled = ToggleGroup("Use Texture", data.enabled); //EditorGUILayout.Toggle ("Use Texture",data.enabled); //data.enabled = ToggleGroup ("Use Texture",data.enabled); if (!data.enabled) { return; } bool preGUI = GUI.enabled; GUI.enabled = data.enabled && GUI.enabled; EditorGUI.indentLevel++; //data.source = EditorGUILayout.ObjectField ("Source",data.source,typeof(Texture2D),false) as Texture2D; data.source = ObjectField("Source", data.source, typeof(Texture2D), false) as Texture2D; if (data.source != null) { string path = AssetDatabase.GetAssetPath(data.source); if (path != "") { TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter; if (!importer.isReadable) { if (FixLabel("Texture is not readable")) { importer.isReadable = true; EditorUtility.SetDirty(importer); AssetDatabase.ImportAsset(path); } } } } for (int i = 0; i < 3; i++) { string channelName = i == 0 ? "R" : (i == 1 ? "G" : "B"); data.channels[i] = (GridGraph.TextureData.ChannelUse)EditorGUILayout.Popup(channelName, (int)data.channels[i], ChannelUseNames); if (data.channels[i] != GridGraph.TextureData.ChannelUse.None) { EditorGUI.indentLevel++; data.factors[i] = EditorGUILayout.FloatField("Factor", data.factors[i]); string help = ""; switch (data.channels[i]) { case GridGraph.TextureData.ChannelUse.Penalty: help = "Nodes are applied penalty according to channel '" + channelName + "', multiplied with factor"; break; case GridGraph.TextureData.ChannelUse.Position: help = "Nodes Y position is changed according to channel '" + channelName + "', multiplied with factor"; if (graph.collision.heightCheck) { HelpBox("Getting position both from raycast and from texture. You should disable one of them"); } break; case GridGraph.TextureData.ChannelUse.WalkablePenalty: help = "If channel '" + channelName + "' is 0, the node is made unwalkable. Otherwise the node is applied penalty multiplied with factor"; break; } HelpBox(help); EditorGUI.indentLevel--; } } if (GUILayout.Button("Generate Reference")) { SaveReferenceTexture(graph); } GUI.enabled = preGUI; EditorGUI.indentLevel--; }
protected override void DrawTextureData(GridGraph.TextureData data, GridGraph graph) { // No texture data for layered grid graphs }