Adding A* Algorythm and carpet roads

This commit is contained in:
Nicolas SANS
2023-04-24 15:49:03 +02:00
parent 75018ee6cd
commit 690e3fbd0b
685 changed files with 134125 additions and 19 deletions

View File

@ -0,0 +1,17 @@
using UnityEditor;
namespace Pathfinding.Legacy {
[CustomEditor(typeof(LegacyAIPath))]
[CanEditMultipleObjects]
public class LegacyAIPathEditor : BaseAIEditor {
protected override void Inspector () {
base.Inspector();
var gravity = FindProperty("gravity");
if (!gravity.hasMultipleDifferentValues && !float.IsNaN(gravity.vector3Value.x)) {
gravity.vector3Value = new UnityEngine.Vector3(float.NaN, float.NaN, float.NaN);
serializedObject.ApplyModifiedPropertiesWithoutUndo();
}
LegacyEditorHelper.UpgradeDialog(targets, typeof(AIPath));
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5075ffc0df8c943368fa824db55589b4
timeCreated: 1491232013
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,29 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
namespace Pathfinding.Legacy {
public static class LegacyEditorHelper {
public static void UpgradeDialog (Object[] targets, System.Type upgradeType) {
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
var gui = EditorGUIUtility.IconContent("console.warnicon");
gui.text = "You are using the compatibility version of this component. It is recommended that you upgrade to the newer version. This may change the component's behavior.";
EditorGUILayout.LabelField(GUIContent.none, gui, EditorStyles.wordWrappedMiniLabel);
if (GUILayout.Button("Upgrade")) {
Undo.RecordObjects(targets.Select(s => (s as Component).gameObject).ToArray(), "Upgrade from Legacy Component");
foreach (var tg in targets) {
var comp = tg as Component;
var components = comp.gameObject.GetComponents<Component>();
int index = System.Array.IndexOf(components, comp);
var newRVO = Undo.AddComponent(comp.gameObject, upgradeType);
foreach (var field in newRVO.GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public)) {
field.SetValue(newRVO, field.GetValue(comp));
}
Undo.DestroyObjectImmediate(comp);
for (int i = components.Length - 1; i > index; i--) UnityEditorInternal.ComponentUtility.MoveComponentUp(newRVO);
}
}
EditorGUILayout.EndVertical();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a97cec2d4f06c4d0eb0068c24cb47ca1
timeCreated: 1490879139
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: