Skip to content

Commit

Permalink
update to Unity 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
h8man committed Apr 15, 2024
1 parent 576ec35 commit dd2842a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 88 deletions.
10 changes: 2 additions & 8 deletions NavMeshComponents/Editor/AgentOverride2dEditor.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using NavMeshPlus.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditor;

namespace NavMeshPlus.Editors.Extensions
namespace NavMeshPlus.Extensions.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(AgentOverride2d))]
Expand Down
6 changes: 2 additions & 4 deletions NavMeshComponents/Editor/CollectSources2dEditor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using UnityEngine.AI;
using UnityEngine;
using UnityEngine;
using UnityEditor;
using NavMeshPlus.Extensions;

namespace NavMeshPlus.Editors.Extensions
namespace NavMeshPlus.Extensions.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(CollectSources2d))]
Expand Down
6 changes: 2 additions & 4 deletions NavMeshComponents/Editor/CollectSourcesCache2dEditor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using UnityEngine.AI;
using UnityEngine;
using UnityEngine;
using UnityEditor;
using NavMeshPlus.Extensions;

namespace NavMeshPlus.Editors.Extensions
namespace NavMeshPlus.Extensions.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(CollectSourcesCache2d))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using NavMeshPlus.Components.Editors;
using UnityEditor;
using UnityEngine;
using NavMeshPlus.Extensions;
using NavMeshPlus.Editors.Components;


//***********************************************************************************
// Contributed by author jl-randazzo github.com/jl-randazzo
//***********************************************************************************
namespace NavMeshPlus.Editors.Extensions
namespace NavMeshPlus.Extensions.Editors
{
[CustomPropertyDrawer(typeof(NavMeshAgentAttribute))]
public class NavMeshAgentAttributePropertyDrawer : PropertyDrawer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using NavMeshPlus.Components.Editors;
using UnityEditor;
using UnityEngine;
using NavMeshPlus.Extensions;
using NavMeshPlus.Editors.Components;

//***********************************************************************************
// Contributed by author jl-randazzo github.com/jl-randazzo
//***********************************************************************************
namespace NavMeshPlus.Editors.Extensions
namespace NavMeshPlus.Extensions.Editors
{
[CustomPropertyDrawer(typeof(NavMeshAreaAttribute))]
public class NavMeshAreaAttributePropertyDrawer : PropertyDrawer
Expand Down
5 changes: 1 addition & 4 deletions NavMeshComponents/Editor/NavMeshAssetManager.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System.Collections.Generic;
using System.IO;
using UnityEditor.Experimental.SceneManagement;
using UnityEditor.SceneManagement;
using UnityEngine.AI;
using UnityEngine;
using NavMeshPlus.Extensions;
using UnityEditor;
using NavMeshPlus.Components;

namespace NavMeshPlus.Editors.Components
namespace NavMeshPlus.Components.Editors
{
public class NavMeshAssetManager : ScriptableSingleton<NavMeshAssetManager>
{
Expand Down
2 changes: 1 addition & 1 deletion NavMeshComponents/Editor/NavMeshComponentsGUIUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UnityEngine;
using UnityEngine.AI;

namespace NavMeshPlus.Editors.Components
namespace NavMeshPlus.Components.Editors
{
public static class NavMeshComponentsGUIUtility
{
Expand Down
24 changes: 11 additions & 13 deletions NavMeshComponents/Editor/NavMeshLinkEditor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using NavMeshPlus.Components;
using UnityEditor;
using UnityEditor.AI;
using UnityEngine;
using UnityEngine.AI;

namespace NavMeshPlus.Editors.Components
namespace NavMeshPlus.Components.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(NavMeshLink))]
Expand Down Expand Up @@ -39,14 +36,11 @@ void OnEnable()
s_SelectedID = 0;
s_SelectedPoint = -1;

NavMeshVisualizationSettings.showNavigation++;
}

void OnDisable()
{
NavMeshVisualizationSettings.showNavigation--;
}



static Matrix4x4 UnscaledLocalToWorldMatrix(Transform t)
{
return Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Expand Down Expand Up @@ -137,10 +131,12 @@ static void DrawLink(NavMeshLink navLink)
Gizmos.DrawLine(navLink.startPoint + right * rad, navLink.endPoint + right * rad);
}

[DrawGizmo(GizmoType.Selected | GizmoType.Active | GizmoType.Pickable)]

[DrawGizmo(GizmoType.InSelectionHierarchy | GizmoType.Active | GizmoType.Pickable)]

static void RenderBoxGizmo(NavMeshLink navLink, GizmoType gizmoType)
{
if (!EditorApplication.isPlaying)
if (!EditorApplication.isPlaying && navLink.isActiveAndEnabled)
navLink.UpdateLink();

var color = s_HandleColor;
Expand All @@ -164,7 +160,9 @@ static void RenderBoxGizmo(NavMeshLink navLink, GizmoType gizmoType)
[DrawGizmo(GizmoType.NotInSelectionHierarchy | GizmoType.Pickable)]
static void RenderBoxGizmoNotSelected(NavMeshLink navLink, GizmoType gizmoType)
{
if (NavMeshVisualizationSettings.showNavigation > 0)
if (!EditorApplication.isPlaying && navLink.isActiveAndEnabled)
navLink.UpdateLink();

{
var color = s_HandleColor;
if (!navLink.enabled)
Expand Down Expand Up @@ -268,7 +266,7 @@ public void OnSceneGUI()
}

[MenuItem("GameObject/Navigation/NavMesh Link", false, 2002)]
static public void CreateNavMeshLink(MenuCommand menuCommand)
public static void CreateNavMeshLink(MenuCommand menuCommand)
{
var parent = menuCommand.context as GameObject;
GameObject go = NavMeshComponentsGUIUtility.CreateAndSelectGameObject("NavMesh Link", parent);
Expand Down
13 changes: 3 additions & 10 deletions NavMeshComponents/Editor/NavMeshModifierEditor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using NavMeshPlus.Components;
using NavMeshPlus.Extensions;
using UnityEditor;
using UnityEditor.AI;
using UnityEngine.AI;

namespace NavMeshPlus.Editors.Components
namespace NavMeshPlus.Components.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(NavMeshModifier))]
Expand All @@ -22,14 +18,11 @@ void OnEnable()
m_IgnoreFromBuild = serializedObject.FindProperty("m_IgnoreFromBuild");
m_OverrideArea = serializedObject.FindProperty("m_OverrideArea");

NavMeshVisualizationSettings.showNavigation++;
}

void OnDisable()
{
NavMeshVisualizationSettings.showNavigation--;
}



public override void OnInspectorGUI()
{
serializedObject.Update();
Expand Down
8 changes: 1 addition & 7 deletions NavMeshComponents/Editor/NavMeshModifierTilemapEditor.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
using NavMeshPlus.Components;
using NavMeshPlus.Extensions;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEditor.AI;
using UnityEngine.AI;
using UnityEngine.Tilemaps;

//***********************************************************************************
// Contributed by author jl-randazzo github.com/jl-randazzo
//***********************************************************************************
namespace NavMeshPlus.Editors.Components
namespace NavMeshPlus.Components.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(NavMeshModifierTilemap))]
Expand Down
20 changes: 4 additions & 16 deletions NavMeshComponents/Editor/NavMeshModifierVolumeEditor.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using UnityEditor.IMGUI.Controls;
using UnityEditorInternal;
using UnityEngine.AI;
using UnityEngine;
using NavMeshPlus.Extensions;
using UnityEditor;
using UnityEditor.AI;
using NavMeshPlus.Components;

namespace NavMeshPlus.Editors.Components
namespace NavMeshPlus.Components.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(NavMeshModifierVolume))]
Expand All @@ -33,15 +29,7 @@ void OnEnable()
m_AffectedAgents = serializedObject.FindProperty("m_AffectedAgents");
m_Area = serializedObject.FindProperty("m_Area");
m_Center = serializedObject.FindProperty("m_Center");
m_Size = serializedObject.FindProperty("m_Size");

NavMeshVisualizationSettings.showNavigation++;
}

void OnDisable()
{
NavMeshVisualizationSettings.showNavigation--;
}
m_Size = serializedObject.FindProperty("m_Size"); }

Bounds GetBounds()
{
Expand All @@ -65,7 +53,8 @@ public override void OnInspectorGUI()
serializedObject.ApplyModifiedProperties();
}

[DrawGizmo(GizmoType.Selected | GizmoType.Active)]

[DrawGizmo(GizmoType.InSelectionHierarchy | GizmoType.Active)]
static void RenderBoxGizmo(NavMeshModifierVolume navModifier, GizmoType gizmoType)
{
var color = navModifier.enabled ? s_HandleColor : s_HandleColorDisabled;
Expand All @@ -91,7 +80,6 @@ static void RenderBoxGizmo(NavMeshModifierVolume navModifier, GizmoType gizmoTyp
[DrawGizmo(GizmoType.NotInSelectionHierarchy | GizmoType.Pickable)]
static void RenderBoxGizmoNotSelected(NavMeshModifierVolume navModifier, GizmoType gizmoType)
{
if (NavMeshVisualizationSettings.showNavigation > 0)
{
var color = navModifier.enabled ? s_HandleColor : s_HandleColorDisabled;
var oldColor = Gizmos.color;
Expand Down
16 changes: 6 additions & 10 deletions NavMeshComponents/Editor/NavMeshSurfaceEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using UnityEngine;
using UnityEditor;
using UnityEditor.AI;
using NavMeshPlus.Components;
using System.Reflection;

namespace NavMeshPlus.Editors.Components
namespace NavMeshPlus.Components.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(NavMeshSurface))]
Expand Down Expand Up @@ -77,14 +77,10 @@ void OnEnable()
#if NAVMESHCOMPONENTS_SHOW_NAVMESHDATA_REF
m_NavMeshData = serializedObject.FindProperty("m_NavMeshData");
#endif
NavMeshVisualizationSettings.showNavigation++;
}

void OnDisable()
{
NavMeshVisualizationSettings.showNavigation--;
}


Bounds GetBounds()
{
var navSurface = (NavMeshSurface)target;
Expand Down Expand Up @@ -305,16 +301,16 @@ public override void OnInspectorGUI()
[DrawGizmo(GizmoType.Selected | GizmoType.Active | GizmoType.Pickable)]
static void RenderBoxGizmoSelected(NavMeshSurface navSurface, GizmoType gizmoType)
{
//navSurface.navMeshDataInstance.FlagAsInSelectionHierarchy();
var method = navSurface.navMeshDataInstance.GetType().GetMethod("FlagAsInSelectionHierarchy", BindingFlags.NonPublic | BindingFlags.Instance);
method.Invoke(navSurface.navMeshDataInstance, null);
RenderBoxGizmo(navSurface, gizmoType, true);
}

[DrawGizmo(GizmoType.NotInSelectionHierarchy | GizmoType.Pickable)]
static void RenderBoxGizmoNotSelected(NavMeshSurface navSurface, GizmoType gizmoType)
{
if (NavMeshVisualizationSettings.showNavigation > 0)
RenderBoxGizmo(navSurface, gizmoType, false);
else
Gizmos.DrawIcon(navSurface.transform.position, "NavMeshSurface Icon", true);
}

static void RenderBoxGizmo(NavMeshSurface navSurface, GizmoType gizmoType, bool selected)
Expand Down
7 changes: 2 additions & 5 deletions NavMeshComponents/Editor/RootSources2dEditor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using UnityEngine.AI;
using UnityEngine;
using UnityEditor;
using NavMeshPlus.Extensions;
using UnityEditor;
using NavMeshPlus.Components;

namespace NavMeshPlus.Editors.Extensions
namespace NavMeshPlus.Extensions.Editors
{
[CanEditMultipleObjects]
[CustomEditor(typeof(RootSources2d))]
Expand Down
2 changes: 2 additions & 0 deletions NavMeshComponents/Scripts/NavMeshSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public class NavMeshSurface : MonoBehaviour
Vector3 m_LastPosition = Vector3.zero;
Quaternion m_LastRotation = Quaternion.identity;

public NavMeshDataInstance navMeshDataInstance => m_NavMeshDataInstance;

static readonly List<NavMeshSurface> s_NavMeshSurfaces = new List<NavMeshSurface>();
public INavMeshExtensionsProvider NevMeshExtensions { get; set; } = new NavMeshExtensionsProvider();

Expand Down

0 comments on commit dd2842a

Please sign in to comment.