Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kipash committed Jun 26, 2024
1 parent 168b652 commit a510a5b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 11 deletions.
45 changes: 45 additions & 0 deletions package/Runtime/Navmesh/Navmesh.unity
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,51 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &238852865
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 238852867}
- component: {fileID: 238852866}
m_Layer: 0
m_Name: Requires Navmesh package
m_TagString: EditorOnly
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &238852866
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 238852865}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c3dd69e66499fb84aaaa99015c703d1c, type: 3}
m_Name:
m_EditorClassIdentifier: Needle.Engine.RequirePackage, Needle.Engine-Samples.Runtime
packageName: com.unity.ai.navigation
--- !u!4 &238852867
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 238852865}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 4.280514, y: -5.3953648, z: 1.8847513}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 14
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &399847920
GameObject:
m_ObjectHideFlags: 0
Expand Down
8 changes: 4 additions & 4 deletions package/Runtime/Splines/Splines.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &509490561
GameObject:
Expand Down Expand Up @@ -1335,7 +1335,7 @@ Transform:
- {fileID: 545388694}
- {fileID: 777419205}
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &545388693
GameObject:
Expand Down Expand Up @@ -1645,8 +1645,8 @@ GameObject:
- component: {fileID: 1091126112}
- component: {fileID: 1091126111}
m_Layer: 0
m_Name: Require Splines Package
m_TagString: Untagged
m_Name: Requires Splines Package
m_TagString: EditorOnly
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
Expand Down
25 changes: 18 additions & 7 deletions package/Runtime/_Internal/RequirePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ internal class RequirePackageEditor : Editor
{
private bool isInstalled = false;
private bool isInstalling = false;
internal static bool IsInstalled(RequirePackage pkg) => File.Exists($"Packages/{pkg.packageName}/package.json");
internal static string GetPackageName(RequirePackage pkg)
{
if (!pkg) return string.Empty;
#if !UNITY_2022_1_OR_NEWER
if (pkg.packageName == "com.unity.ai.navigation")
return "com.unity.modules.ai";
#endif
return pkg.packageName;
}
internal static bool IsInstalled(RequirePackage pkg) => File.Exists($"Packages/{GetPackageName(pkg)}/package.json");

private void OnEnable()
{
Expand All @@ -58,21 +67,23 @@ public override void OnInspectorGUI()
{
var t = target as RequirePackage;
if (!t) return;

var packageName = GetPackageName(t);

if (isInstalled)
EditorGUILayout.LabelField("✓ Package \"" + t.packageName + "\" is installed");
EditorGUILayout.LabelField("✓ Package \"" + packageName + "\" is installed");
else if (isInstalling)
{
EditorGUI.BeginDisabledGroup(true);
GUILayout.Button("Installing package \"" + t.packageName + "\"...");
GUILayout.Button("Installing package \"" + packageName + "\"...");
EditorGUI.EndDisabledGroup();
}
else
{
EditorGUILayout.HelpBox($"The package \"{t.packageName}\" is required for this sample to work.", MessageType.Warning);
if (GUILayout.Button($"Install {t.packageName}"))
EditorGUILayout.HelpBox($"The package \"{packageName}\" is required for this sample to work.", MessageType.Warning);
if (GUILayout.Button($"Install {packageName}"))
{
Client.Add(t.packageName);
Client.Add(packageName);
isInstalling = true;
}
}
Expand All @@ -81,7 +92,7 @@ public override void OnInspectorGUI()
[MenuItem("CONTEXT/RequirePackage/Uninstall Package")]
static void RemovePackage(MenuCommand cmd)
{
Client.Remove((cmd.context as RequirePackage)?.packageName);
Client.Remove(GetPackageName(cmd.context as RequirePackage));
}
}
#endif
Expand Down

0 comments on commit a510a5b

Please sign in to comment.