public void OnInspectorGUI() { var skin = InspectorEditor.Skin; using (GUI.AlignBlock.Center) GUILayout.Label(GUI.MakeLabel("AGXUnity Editor Settings", 24, true), skin.Label); BuildPlayer_CopyBinaries = InspectorGUI.Toggle(GUI.MakeLabel("<b>Build:</b> Copy AGX Dynamics binaries", false, "[Recommended enabled]\nCopy dependent AGX Dynamics binaries to target player directory."), BuildPlayer_CopyBinaries); AGXDynamics_LogPath = InspectorGUI.ToggleSaveFile(GUI.MakeLabel("AGX Dynamics log"), AGXDynamics_LogEnabled, enable => AGXDynamics_LogEnabled = enable, AGXDynamics_LogPath, "AGXDynamicsLog", "txt", "AGX Dynamics log filename", extension => true); if (ExternalAGXInitializer.IsApplied) { DirectoryInfo newAgxDir = null; if (InspectorGUI.SelectFolder(GUI.MakeLabel("AGX Dynamics directory"), ExternalAGXInitializer.Instance.AGX_DIR, "AGX Dynamics directory", newFolder => newAgxDir = new DirectoryInfo(newFolder))) { if (ExternalAGXInitializer.FindType(newAgxDir) == ExternalAGXInitializer.AGXDirectoryType.Unknown) { Debug.LogError($"ERROR: {newAgxDir.FullName} doesn't seems to be an AGX Dynamics root folder."); } else if (EditorUtility.DisplayDialog("Change AGX Dynamics directory", $"Change from {ExternalAGXInitializer.Instance.AGX_DIR} to {newAgxDir.FullName}?\n\n" + "Unity will restart during the change.", "Yes", "Cancel")) { ExternalAGXInitializer.ChangeRootDirectory(newAgxDir); } } } else if (!IO.Utils.AGXDynamicsInstalledInProject && ExternalAGXInitializer.UserSaidNo) { var rect = EditorGUILayout.GetControlRect(); var orgWidth = rect.width; rect.width = EditorGUIUtility.labelWidth; EditorGUI.PrefixLabel(rect, GUI.MakeLabel("Select AGX Dynamics root folder"), skin.Label); rect.x += rect.width; rect.width = orgWidth - EditorGUIUtility.labelWidth; if (UnityEngine.GUI.Button(rect, GUI.MakeLabel("AGX Dynamics root directory..."))) { var agxDir = EditorUtility.OpenFolderPanel("AGX Dynamics root directory", "Assets", ""); if (!string.IsNullOrEmpty(agxDir)) { var agxDirInfo = new DirectoryInfo(agxDir); var type = ExternalAGXInitializer.FindType(agxDirInfo); if (type == ExternalAGXInitializer.AGXDirectoryType.Unknown) { Debug.LogWarning($"{agxDir} isn't recognized as an AGX Dynamics root directory."); } else if (EditorUtility.DisplayDialog("Add AGX Dynamics directory", $"Set AGX Dynamics root directory to {agxDir}?\n\n" + "Unity will restart during the process.", "Yes", "Cancel")) { ExternalAGXInitializer.UserSaidNo = false; ExternalAGXInitializer.ChangeRootDirectory(agxDirInfo); } } } } InspectorGUI.Separator(1, 4); // BuiltInToolsTool settings GUI. { HandleKeyHandlerGUI(GUI.MakeLabel("Select game object"), BuiltInToolsTool_SelectGameObjectKeyHandler); HandleKeyHandlerGUI(GUI.MakeLabel("Select rigid body game object"), BuiltInToolsTool_SelectRigidBodyKeyHandler); HandleKeyHandlerGUI(GUI.MakeLabel("Pick handler (scene view)"), BuiltInToolsTool_PickHandlerKeyHandler); } }
internal static EnvironmentState ConfigureEnvironment() { #if AGXUNITY_UPDATING Debug.LogWarning("AGX Dynamics for Unity is currently updating..."); return(EnvironmentState.Updating); #else // WARNING INFO: // Unity 2018, 2019: AGX Dynamics for Unity compiles but undefined behavior // in players with API compatibility @ .NET Standard 2.0. // Unity 2017: AGX Dynamics for Unity won't compile due to if (PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.Standalone) != ApiCompatibilityLevel.NET_4_6) { Debug.LogWarning(AGXUnity.Utils.GUI.AddColorTag("<b>WARNING:</b> ", Color.yellow) + "AGX Dynamics for Unity requires .NET API compatibility level: .NET 4.x.\n" + "<b>Edit -> Project Settings... -> Player -> Other Settings -> Configuration -> Api Compatibility Level -> .NET 4.x</b>"); } // Running from within the editor - two options: // 1. Unity has been started from an AGX environment => do nothing. // 2. AGX Dynamics dll's are present in the plugins directory => setup // environment file paths. var binariesInProject = IO.Utils.AGXDynamicsInstalledInProject; if (binariesInProject) { // This is necessary when e.g., terrain dynamically loads dll's. AGXUnity.IO.Environment.AddToPath(IO.Utils.AGXUnityPluginDirectoryFull); try { AGXUnity.NativeHandler.Instance.Register(null); } catch (TypeInitializationException) { var lastRequestData = GetRequestScriptReloadData(); if ((float)EditorApplication.timeSinceStartup - lastRequestData.Float > 1.0f) { lastRequestData.Float = (float)EditorApplication.timeSinceStartup; #if UNITY_2019_3_OR_NEWER Debug.LogWarning("AGX Dynamics binaries aren't properly loaded into Unity - requesting Unity to reload assemblies..."); EditorUtility.RequestScriptReload(); #else Debug.LogWarning("AGX Dynamics binaries aren't properly loaded into Unity - restart Unity manually."); #endif } return(EnvironmentState.Uninitialized); } catch (Exception e) { Debug.LogException(e); return(EnvironmentState.Uninitialized); } if (!AGXUnity.IO.Environment.IsSet(AGXUnity.IO.Environment.Variable.AGX_DIR)) { AGXUnity.IO.Environment.Set(AGXUnity.IO.Environment.Variable.AGX_DIR, IO.Utils.AGXUnityPluginDirectoryFull); } if (!AGXUnity.IO.Environment.IsSet(AGXUnity.IO.Environment.Variable.AGX_PLUGIN_PATH)) { AGXUnity.IO.Environment.Set(AGXUnity.IO.Environment.Variable.AGX_PLUGIN_PATH, IO.Utils.AGXUnityPluginDirectoryFull + Path.DirectorySeparatorChar + "agx"); } var envInstance = agxIO.Environment.instance(); for (int i = 0; i < (int)agxIO.Environment.Type.NUM_TYPES; ++i) { envInstance.getFilePath((agxIO.Environment.Type)i).clear(); } envInstance.getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath("."); envInstance.getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(IO.Utils.AGXUnityPluginDirectoryFull); envInstance.getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(AGXUnity.IO.Environment.Get(AGXUnity.IO.Environment.Variable.AGX_PLUGIN_PATH)); envInstance.getFilePath(agxIO.Environment.Type.RUNTIME_PATH).pushbackPath(AGXUnity.IO.Environment.Get(AGXUnity.IO.Environment.Variable.AGX_PLUGIN_PATH)); } else { ExternalAGXInitializer.Initialize(); } // This validate is only for "license status" window so // the user will be noticed when something is wrong. try { AGXUnity.NativeHandler.Instance.ValidateLicense(); if (EditorSettings.Instance.AGXDynamics_LogEnabled && !string.IsNullOrEmpty(EditorSettings.Instance.AGXDynamics_LogPath.Trim())) { agx.Logger.instance().openLogfile(EditorSettings.Instance.AGXDynamics_LogPath.Trim(), true, true); } } catch (Exception) { return(EnvironmentState.Uninitialized); } return(EnvironmentState.Initialized); #endif }
internal static EnvironmentState ConfigureEnvironment() { #if AGXUNITY_UPDATING Debug.LogWarning("AGX Dynamics for Unity is currently updating..."); return(EnvironmentState.Updating); #else // WARNING INFO: // Unity 2018, 2019: AGX Dynamics for Unity compiles but undefined behavior // in players with API compatibility @ .NET Standard 2.0. // Unity 2017: AGX Dynamics for Unity won't compile due to if (PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.Standalone) != ApiCompatibilityLevel.NET_4_6) { Debug.LogWarning(AGXUnity.Utils.GUI.AddColorTag("<b>WARNING:</b> ", Color.yellow) + "AGX Dynamics for Unity requires .NET API compatibility level: .NET 4.x.\n" + "<b>Edit -> Project Settings... -> Player -> Other Settings -> Configuration -> Api Compatibility Level -> .NET 4.x</b>"); } // Running from within the editor - two options: // 1. Unity has been started from an AGX environment => do nothing. // 2. AGX Dynamics dll's are present in the plugins directory => setup // environment file paths. var binariesInProject = IO.Utils.AGXDynamicsInstalledInProject; if (binariesInProject) { // This is necessary when e.g., terrain dynamically loads dll's. AGXUnity.IO.Environment.AddToPath(IO.Utils.AGXUnityPluginDirectoryFull); var initSuccess = false; try { AGXUnity.NativeHandler.Instance.Register(null); initSuccess = true; } catch (Exception) { } if (!HandleScriptReload(initSuccess)) { return(EnvironmentState.Uninitialized); } if (!AGXUnity.IO.Environment.IsSet(AGXUnity.IO.Environment.Variable.AGX_DIR)) { AGXUnity.IO.Environment.Set(AGXUnity.IO.Environment.Variable.AGX_DIR, IO.Utils.AGXUnityPluginDirectoryFull); } if (!AGXUnity.IO.Environment.IsSet(AGXUnity.IO.Environment.Variable.AGX_PLUGIN_PATH)) { AGXUnity.IO.Environment.Set(AGXUnity.IO.Environment.Variable.AGX_PLUGIN_PATH, IO.Utils.AGXUnityPluginDirectoryFull + Path.DirectorySeparatorChar + "agx"); } var envInstance = agxIO.Environment.instance(); for (int i = 0; i < (int)agxIO.Environment.Type.NUM_TYPES; ++i) { envInstance.getFilePath((agxIO.Environment.Type)i).clear(); } // Adding Plugins/x86_64/agx to RESOURCE_PATH (for additional data) and // to RUNTIME_PATH (for entities and components). The license file is // searched for by the license manager. var dataAndRuntimePath = AGXUnity.IO.Environment.Get(AGXUnity.IO.Environment.Variable.AGX_PLUGIN_PATH); envInstance.getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(dataAndRuntimePath); envInstance.getFilePath(agxIO.Environment.Type.RUNTIME_PATH).pushbackPath(dataAndRuntimePath); } // Check if user would like to initialize AGX Dynamics with an // installed (or Algoryx developer) version. else { if (!HandleScriptReload(ExternalAGXInitializer.Initialize())) { return(EnvironmentState.Uninitialized); } } // This validate is only for "license status" window so // the user will be noticed when something is wrong. try { AGXUnity.LicenseManager.LoadFile(); AGXUnity.NativeHandler.Instance.ValidateLicense(); if (EditorSettings.Instance.AGXDynamics_LogEnabled && !string.IsNullOrEmpty(EditorSettings.Instance.AGXDynamics_LogPath.Trim())) { agx.Logger.instance().openLogfile(EditorSettings.Instance.AGXDynamics_LogPath.Trim(), true, true); } } catch (Exception) { return(EnvironmentState.Uninitialized); } return(EnvironmentState.Initialized); #endif }