TagField() public static method

public static TagField ( string label, int value ) : int
label string
value int
return int
Esempio n. 1
0
        protected void DrawErosion(GridGraph graph)
        {
            graph.erodeIterations = EditorGUILayout.IntField(new GUIContent("Erosion iterations", "Sets how many times the graph should be eroded. This adds extra margin to objects."), graph.erodeIterations);
            graph.erodeIterations = graph.erodeIterations < 0 ? 0 : (graph.erodeIterations > 16 ? 16 : graph.erodeIterations);             //Clamp iterations to [0,16]

            if (graph.erodeIterations > 0)
            {
                EditorGUI.indentLevel++;
                graph.erosionUseTags = EditorGUILayout.Toggle(new GUIContent("Erosion Uses Tags", "Instead of making nodes unwalkable, " +
                                                                             "nodes will have their tag set to a value corresponding to their erosion level, " +
                                                                             "which is a quite good measurement of their distance to the closest wall.\nSee online documentation for more info."),
                                                              graph.erosionUseTags);
                if (graph.erosionUseTags)
                {
                    EditorGUI.indentLevel++;
                    graph.erosionFirstTag = EditorGUILayoutx.TagField("First Tag", graph.erosionFirstTag, () => AstarPathEditor.EditTags());
                    EditorGUI.indentLevel--;
                }
                EditorGUI.indentLevel--;
            }
        }
Esempio n. 2
0
        void DrawTagField()
        {
            EditorGUILayout.PropertyField(modifyTag, new GUIContent("Modify Tag", "Should the tags of the nodes be modified"));
            if (!modifyTag.hasMultipleDifferentValues && modifyTag.boolValue)
            {
                EditorGUI.indentLevel++;
                EditorGUI.showMixedValue = tagValue.hasMultipleDifferentValues;
                EditorGUI.BeginChangeCheck();
                var newTag = EditorGUILayoutx.TagField("Tag Value", tagValue.intValue);
                if (EditorGUI.EndChangeCheck())
                {
                    tagValue.intValue = newTag;
                }
                EditorGUI.indentLevel--;
            }

            if (GUILayout.Button("Tags can be used to restrict which units can walk on what ground. Click here for more info", "HelpBox"))
            {
                Application.OpenURL(AstarUpdateChecker.GetURL("tags"));
            }
        }
Esempio n. 3
0
        void DrawTagField()
        {
            if (PropertyField("modifyTag"))
            {
                var tagValue = FindProperty("setTag");
                EditorGUI.indentLevel++;
                EditorGUI.showMixedValue = tagValue.hasMultipleDifferentValues;
                EditorGUI.BeginChangeCheck();
                var newTag = EditorGUILayoutx.TagField("Tag Value", tagValue.intValue);
                if (EditorGUI.EndChangeCheck())
                {
                    tagValue.intValue = newTag;
                }

                if (GUILayout.Button("Tags can be used to restrict which units can walk on what ground. Click here for more info", "HelpBox"))
                {
                    Application.OpenURL(AstarUpdateChecker.GetURL("tags"));
                }
                EditorGUI.indentLevel--;
            }
        }
        /** Draws settings for using a texture as source for a grid.
         * \astarpro
         */
        protected virtual void DrawTextureData(GridGraph.TextureData data, GridGraph graph)
        {
            if (data == null)
            {
                return;
            }

            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 = ObjectField("Source", data.source, typeof(Texture2D), false) as Texture2D;

            if (data.source != null)
            {
                string path = AssetDatabase.GetAssetPath(data.source);

                if (path != "")
                {
                    var importer = AssetImporter.GetAtPath(path) as TextureImporter;
                    if (!importer.isReadable)
                    {
                        if (FixLabel("Texture is not readable"))
                        {
                            importer.isReadable = true;
                            EditorUtility.SetDirty(importer);
                            AssetDatabase.ImportAsset(path);
                        }
                    }
                }
            }

            string[] channelNames = { "R", "G", "B", "A", "All" };
            for (int i = 0; i < data.channels.Length; i++)
            {
                string channelName = channelNames[i];
                data.channels[i] = (GridGraph.TextureData.ChannelUse)EditorGUILayout.Popup(channelName, (int)data.channels[i], ChannelUseNames);

                if (data.channels[i] != GridGraph.TextureData.ChannelUse.None)
                {
                    EditorGUI.indentLevel++;

                    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;

                    case GridGraph.TextureData.ChannelUse.Tag:
                        help = "factor need be AstarPath.TagNames";
                        break;
                    }
                    if (data.channels[i] != GridGraph.TextureData.ChannelUse.Tag)
                    {
                        data.factors[i] = EditorGUILayout.FloatField("Factor", data.factors[i]);
                    }
                    else
                    {
                        data.factors[i] = EditorGUILayoutx.TagField("Tag Value", (int)data.factors[i]);
                    }
                    HelpBox(help);

                    EditorGUI.indentLevel--;
                }
            }

            if (GUILayout.Button("Generate Reference"))
            {
                SaveReferenceTexture(graph);
            }

            GUI.enabled = preGUI;
            EditorGUI.indentLevel--;
        }