feat: support asset bundle
This commit is contained in:
@@ -47,7 +47,7 @@ namespace OCES.Haptic.Editor
|
||||
};
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Haptic/Create Haptic Settings Asset")]
|
||||
[MenuItem("Tools/OCES/Haptic/Create Haptic Settings Asset")]
|
||||
static void CreateDefaultAsset()
|
||||
{
|
||||
if (!AssetDatabase.IsValidFolder("Assets/Settings"))
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace OCES.Haptic
|
||||
[Tooltip("Resources 子目录:触感资源文件(.haptic)")]
|
||||
public string hapticResourcePath = "Haptics/";
|
||||
|
||||
public bool useAssetBundle = false;
|
||||
public string hapticBundlePath = "Bundles/haptics.ab";
|
||||
|
||||
public static HapticSettings Instance { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Lofelt.NiceVibrations;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -117,6 +118,16 @@ namespace OCES.Haptic
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
this.ResourceLoader = gameObject.AddComponent<ResourceLoader>();
|
||||
if (HapticSettings.Instance.useAssetBundle)
|
||||
{
|
||||
string bundlePath = Path.Combine(Application.streamingAssetsPath,
|
||||
HapticSettings.Instance.hapticBundlePath);
|
||||
this.ResourceLoader.SetProvider(new AssetBundleAssetProvider(bundlePath));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ResourceLoader.SetProvider(new ResourcesAssetProvider());
|
||||
}
|
||||
|
||||
this.m_hapticObjects = HapticConfigLoader.Load<HapticObjectConfig>(HapticSettings.Instance.hapticConfigPath + "HapticObject");
|
||||
this.IsHapticSupported = DeviceCapabilities.isVersionSupported;
|
||||
|
||||
Reference in New Issue
Block a user