Exemplo n.º 1
0
        public void SetValues(object boxedTagMask)
        {
            TagMask tagMask = (TagMask)boxedTagMask;

            this.tagsChange = tagMask.tagsChange;
            this.tagsSet    = tagMask.tagsSet;
        }
Exemplo n.º 2
0
        public void SetValues(System.Object boxedTagMask)
        {
            TagMask o = (TagMask)boxedTagMask;

            tagsChange = o.tagsChange;
            tagsSet    = o.tagsSet;
            //Debug.Log ("Set tags to "+tagsChange +" "+tagsSet+" "+someVar);
        }
Exemplo n.º 3
0
 void ISerializationCallbackReceiver.OnAfterDeserialize()
 {
     if (this.traversableTagsCompatibility != null && this.traversableTagsCompatibility.tagsChange != -1)
     {
         this.traversableTags = this.traversableTagsCompatibility.tagsChange;
         this.traversableTagsCompatibility = new TagMask(-1, -1);
     }
 }
        public static void SetTagField(GUIContent label, ref Pathfinding.TagMask value)
        {
            GUILayout.BeginHorizontal();

            //Debug.Log (value.ToString ());
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            EditorGUIUtility.LookLikeControls();
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            EditorGUILayout.PrefixLabel(label, EditorStyles.layerMaskField);
            //GUILayout.FlexibleSpace ();
            //Rect r = GUILayoutUtility.GetLastRect ();

            string text = "";
            if (value.tagsChange == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsChange == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsChange, 2);
            }

            string[] tagNames = AstarPath.FindTagNames();

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                //Debug.Log ("pre");
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Everything"), value.tagsChange == ~0, value.SetValues, new Pathfinding.TagMask(~0, value.tagsSet));
                menu.AddItem(new GUIContent("Nothing"), value.tagsChange == 0, value.SetValues, new Pathfinding.TagMask(0, value.tagsSet));

                for (int i = 0; i < tagNames.Length; i++)
                {
                    bool on = (value.tagsChange >> i & 0x1) != 0;
                    Pathfinding.TagMask result = new Pathfinding.TagMask(on ? value.tagsChange & ~(1 << i) : value.tagsChange | 1 << i, value.tagsSet);
                    menu.AddItem(new GUIContent(tagNames[i]), on, value.SetValues, result);
                    //value.SetValues (result);
                }

                menu.AddItem(new GUIContent("Edit Tags..."), false, AstarPathEditor.EditTags);
                menu.ShowAsContext();

                Event.current.Use();
                //Debug.Log ("Post");
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();
        }
	public static void TagsMaskField (GUIContent changeLabel, GUIContent setLabel,ref Pathfinding.TagMask value) {
		
		GUILayout.BeginHorizontal ();
		
		//Debug.Log (value.ToString ());
		EditorGUIUtility.LookLikeControls();
		EditorGUILayout.PrefixLabel (changeLabel,EditorStyles.layerMaskField);
		//GUILayout.FlexibleSpace ();
		//Rect r = GUILayoutUtility.GetLastRect ();
		
		string text = "";
		if (value.tagsChange == 0) text = "Nothing";
		else if (value.tagsChange == ~0) text = "Everything";
		else {
			text = System.Convert.ToString (value.tagsChange,2);
		}
		
		if (GUILayout.Button (text,EditorStyles.layerMaskField,GUILayout.ExpandWidth (true))) {
			
			
			//Debug.Log ("pre");
			GenericMenu menu = new GenericMenu ();
			
			menu.AddItem (new GUIContent ("Everything"),value.tagsChange == ~0, value.SetValues, new Pathfinding.TagMask (~0,value.tagsSet));
			menu.AddItem (new GUIContent ("Nothing"),value.tagsChange == 0, value.SetValues, new Pathfinding.TagMask (0,value.tagsSet));
			
			for (int i=0;i<32;i++) {
				bool on = (value.tagsChange >> i & 0x1) != 0;
				Pathfinding.TagMask result = new Pathfinding.TagMask (on ? value.tagsChange & ~(1 << i) : value.tagsChange | 1<<i,value.tagsSet);
				menu.AddItem (new GUIContent (""+i),on,value.SetValues, result);
				//value.SetValues (result);
			}
			
			menu.ShowAsContext ();
			
			Event.current.Use ();
			//Debug.Log ("Post");
		}
		
		EditorGUIUtility.LookLikeInspector();
		GUILayout.EndHorizontal ();
		
		
		
		GUILayout.BeginHorizontal ();
		
		//Debug.Log (value.ToString ());
		EditorGUIUtility.LookLikeControls();
		EditorGUILayout.PrefixLabel (setLabel,EditorStyles.layerMaskField);
		//GUILayout.FlexibleSpace ();
		//r = GUILayoutUtility.GetLastRect ();
		
		text = "";
		if (value.tagsSet == 0) text = "Nothing";
		else if (value.tagsSet == ~0) text = "Everything";
		else {
			text = System.Convert.ToString (value.tagsSet,2);
		}
		
		if (GUILayout.Button (text,EditorStyles.layerMaskField,GUILayout.ExpandWidth (true))) {
			
			
			//Debug.Log ("pre");
			GenericMenu menu = new GenericMenu ();
			
			if (value.tagsChange != 0)	menu.AddItem (new GUIContent ("Everything"),value.tagsSet == ~0, value.SetValues, new Pathfinding.TagMask (value.tagsChange,~0));
			else				menu.AddDisabledItem (new GUIContent ("Everything"));
			
			menu.AddItem (new GUIContent ("Nothing"),value.tagsSet == 0, value.SetValues, new Pathfinding.TagMask (value.tagsChange,0));
			
			for (int i=0;i<32;i++) {
				bool enabled = (value.tagsChange >> i & 0x1) != 0;
				bool on = (value.tagsSet >> i & 0x1) != 0;
				
				Pathfinding.TagMask result = new Pathfinding.TagMask (value.tagsChange, on ? value.tagsSet & ~(1 << i) : value.tagsSet | 1<<i);
				
				if (enabled)	menu.AddItem (new GUIContent (""+i),on,value.SetValues, result);
				else	menu.AddDisabledItem (new GUIContent (""+i));
				
				//value.SetValues (result);
			}
			
			menu.ShowAsContext ();
			
			Event.current.Use ();
			//Debug.Log ("Post");
		}
		
		EditorGUIUtility.LookLikeInspector();
		GUILayout.EndHorizontal ();
		
		
		//return value;
	}
	public static void SetTagField (GUIContent label, ref Pathfinding.TagMask value) {
		
		GUILayout.BeginHorizontal ();
		
		//Debug.Log (value.ToString ());
		EditorGUIUtility.LookLikeControls();
		EditorGUILayout.PrefixLabel (label,EditorStyles.layerMaskField);
		//GUILayout.FlexibleSpace ();
		//Rect r = GUILayoutUtility.GetLastRect ();
		
		string text = "";
		if (value.tagsChange == 0) text = "Nothing";
		else if (value.tagsChange == ~0) text = "Everything";
		else {
			text = System.Convert.ToString (value.tagsChange,2);
		}
		
		string[] tagNames = AstarPath.FindTagNames ();
		
		if (GUILayout.Button (text,EditorStyles.layerMaskField,GUILayout.ExpandWidth (true))) {
			
			//Debug.Log ("pre");
			GenericMenu menu = new GenericMenu ();
			
			menu.AddItem (new GUIContent ("Everything"),value.tagsChange == ~0, value.SetValues, new Pathfinding.TagMask (~0,value.tagsSet));
			menu.AddItem (new GUIContent ("Nothing"),value.tagsChange == 0, value.SetValues, new Pathfinding.TagMask (0,value.tagsSet));
			
			for (int i=0;i<tagNames.Length;i++) {
				bool on = (value.tagsChange >> i & 0x1) != 0;
				Pathfinding.TagMask result = new Pathfinding.TagMask (on ? value.tagsChange & ~(1 << i) : value.tagsChange | 1<<i,value.tagsSet);
				menu.AddItem (new GUIContent (tagNames[i]),on,value.SetValues, result);
				//value.SetValues (result);
			}
			
			menu.AddItem (new GUIContent ("Edit Tags..."),false,AstarPathEditor.EditTags);
			menu.ShowAsContext ();
			
			Event.current.Use ();
			//Debug.Log ("Post");
		}
		
		EditorGUIUtility.LookLikeInspector();
		GUILayout.EndHorizontal ();
		
	}
        public static void TagsMaskField(GUIContent changeLabel, GUIContent setLabel, ref Pathfinding.TagMask value)
        {
            GUILayout.BeginHorizontal();

            //Debug.Log (value.ToString ());
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            EditorGUIUtility.LookLikeControls();
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            EditorGUILayout.PrefixLabel(changeLabel, EditorStyles.layerMaskField);
            //GUILayout.FlexibleSpace ();
            //Rect r = GUILayoutUtility.GetLastRect ();

            string text = "";
            if (value.tagsChange == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsChange == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsChange, 2);
            }

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                //Debug.Log ("pre");
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Everything"), value.tagsChange == ~0, value.SetValues, new Pathfinding.TagMask(~0, value.tagsSet));
                menu.AddItem(new GUIContent("Nothing"), value.tagsChange == 0, value.SetValues, new Pathfinding.TagMask(0, value.tagsSet));

                for (int i = 0; i < 32; i++)
                {
                    bool on = (value.tagsChange >> i & 0x1) != 0;
                    Pathfinding.TagMask result = new Pathfinding.TagMask(on ? value.tagsChange & ~(1 << i) : value.tagsChange | 1 << i, value.tagsSet);
                    menu.AddItem(new GUIContent("" + i), on, value.SetValues, result);
                    //value.SetValues (result);
                }

                menu.ShowAsContext();

                Event.current.Use();
                //Debug.Log ("Post");
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();



            GUILayout.BeginHorizontal();

            //Debug.Log (value.ToString ());
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            EditorGUIUtility.LookLikeControls();
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            EditorGUILayout.PrefixLabel(setLabel, EditorStyles.layerMaskField);
            //GUILayout.FlexibleSpace ();
            //r = GUILayoutUtility.GetLastRect ();

            text = "";
            if (value.tagsSet == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsSet == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsSet, 2);
            }

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                //Debug.Log ("pre");
                GenericMenu menu = new GenericMenu();

                if (value.tagsChange != 0)
                {
                    menu.AddItem(new GUIContent("Everything"), value.tagsSet == ~0, value.SetValues, new Pathfinding.TagMask(value.tagsChange, ~0));
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Everything"));
                }

                menu.AddItem(new GUIContent("Nothing"), value.tagsSet == 0, value.SetValues, new Pathfinding.TagMask(value.tagsChange, 0));

                for (int i = 0; i < 32; i++)
                {
                    bool enabled = (value.tagsChange >> i & 0x1) != 0;
                    bool on      = (value.tagsSet >> i & 0x1) != 0;

                    Pathfinding.TagMask result = new Pathfinding.TagMask(value.tagsChange, on ? value.tagsSet & ~(1 << i) : value.tagsSet | 1 << i);

                    if (enabled)
                    {
                        menu.AddItem(new GUIContent("" + i), on, value.SetValues, result);
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("" + i));
                    }

                    //value.SetValues (result);
                }

                menu.ShowAsContext();

                Event.current.Use();
                //Debug.Log ("Post");
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();


            //return value;
        }
Exemplo n.º 8
0
        public static void TagsMaskField(GUIContent changeLabel, GUIContent setLabel, ref Pathfinding.TagMask value)
        {
            GUILayout.BeginHorizontal();

            EditorGUIUtility.LookLikeControls();
            EditorGUILayout.PrefixLabel(changeLabel, EditorStyles.layerMaskField);

            string text = "";

            if (value.tagsChange == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsChange == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsChange, 2);
            }

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Everything"), value.tagsChange == ~0, value.SetValues, new Pathfinding.TagMask(~0, value.tagsSet));
                menu.AddItem(new GUIContent("Nothing"), value.tagsChange == 0, value.SetValues, new Pathfinding.TagMask(0, value.tagsSet));

                for (int i = 0; i < 32; i++)
                {
                    bool on = (value.tagsChange >> i & 0x1) != 0;
                    Pathfinding.TagMask result = new Pathfinding.TagMask(on ? value.tagsChange & ~(1 << i) : value.tagsChange | 1 << i, value.tagsSet);
                    menu.AddItem(new GUIContent("" + i), on, value.SetValues, result);
                }

                menu.ShowAsContext();

                Event.current.Use();
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            EditorGUIUtility.LookLikeControls();
            EditorGUILayout.PrefixLabel(setLabel, EditorStyles.layerMaskField);

            text = "";
            if (value.tagsSet == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsSet == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsSet, 2);
            }

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                GenericMenu menu = new GenericMenu();

                if (value.tagsChange != 0)
                {
                    menu.AddItem(new GUIContent("Everything"), value.tagsSet == ~0, value.SetValues, new Pathfinding.TagMask(value.tagsChange, ~0));
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Everything"));
                }

                menu.AddItem(new GUIContent("Nothing"), value.tagsSet == 0, value.SetValues, new Pathfinding.TagMask(value.tagsChange, 0));

                for (int i = 0; i < 32; i++)
                {
                    bool enabled = (value.tagsChange >> i & 0x1) != 0;
                    bool on      = (value.tagsSet >> i & 0x1) != 0;

                    Pathfinding.TagMask result = new Pathfinding.TagMask(value.tagsChange, on ? value.tagsSet & ~(1 << i) : value.tagsSet | 1 << i);

                    if (enabled)
                    {
                        menu.AddItem(new GUIContent("" + i), on, value.SetValues, result);
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("" + i));
                    }
                }

                menu.ShowAsContext();

                Event.current.Use();
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();
        }