Unity 6.3
0 онлайн 1 гость 3 в системе
Вход

AndroidExternalToolsSettings.maxJvmHeapSize

Declaration

public static int maxJvmHeapSize;

Описание

Максимальный размер стека Java (в мегабайтах), который будет использоваться для создания приложений Android.

По умолчанию Unity использует 4096 MB и минимальное допустимое значение 128 MB.

using UnityEngine;
using UnityEditor;
using UnityEditor.Android;

public class MaxJvmHeapSizeSample { [MenuItem("Build/Set Custom Max JVM Heap Size")] public static void SetMaxJvmHeapSize() { // Set a custom maximum heap size for the JVM (in MB). Example: 1024 MB int customHeapSize = 1024;

// Ensure the value is at least the minimum allowed (128 MB) if (customHeapSize >= 128) { AndroidExternalToolsSettings.maxJvmHeapSize = customHeapSize; Debug.Log($"Max JVM Heap Size set to: {AndroidExternalToolsSettings.maxJvmHeapSize} MB"); } else { Debug.LogError($"Invalid heap size. The value must be at least 128 MB. Provided: {customHeapSize} MB"); } }

[MenuItem("Build/Get Current Max JVM Heap Size")] public static void GetMaxJvmHeapSize() { // Retrieve the currently configured maximum JVM heap size int currentHeapSize = AndroidExternalToolsSettings.maxJvmHeapSize;

Debug.Log($"Current Max JVM Heap Size: {currentHeapSize} MB");

// Display a warning if the configured heap size is below the minimum allowed if (currentHeapSize < 128) { Debug.LogWarning($"Warning: JVM Heap Size is less than the minimum allowed value (128 MB). Current value: {currentHeapSize} MB"); } } }