69 lines
2.0 KiB
C#
69 lines
2.0 KiB
C#
using Thousandto.Core.Framework;
|
|
using Thousandto.Core.Base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
using FLogger = UnityEngine.Gonbest.MagicCube.FLogger;
|
|
|
|
namespace Thousandto.Plugins.Common
|
|
{
|
|
/// <summary>
|
|
/// 手势操作加载处理
|
|
/// </summary>
|
|
public class FingerGesturesLoader
|
|
{
|
|
#region//常量定义
|
|
//资源路径
|
|
private const string _prefab_MouseGestures = "Default/FingerGestures/Prefabs/Mouse Gestures";
|
|
//资源路径
|
|
private const string _prefab_TouchScreenGestures = "Default/FingerGestures/Prefabs/TouchScreen Gestures";
|
|
#endregion
|
|
|
|
#region//私有变量
|
|
private FingerGestures _fingerGestures = null;
|
|
#endregion
|
|
|
|
#region//初始化 和 卸载 的操作
|
|
public FingerGesturesLoader()
|
|
{
|
|
Initialize();
|
|
}
|
|
//加载
|
|
private void Initialize()
|
|
{
|
|
if (_fingerGestures != null)
|
|
return;
|
|
var prefab = Resources.Load<GameObject>(GetResPath());
|
|
if (prefab != null)
|
|
{
|
|
var go = GameObject.Instantiate(prefab) as GameObject;
|
|
_fingerGestures = go.GetComponent<FingerGestures>();
|
|
//go.hideFlags = HideFlags.HideInHierarchy;
|
|
go.SetActive(true);
|
|
UnityEngine.Object.DontDestroyOnLoad(go);
|
|
//FLogger.Log("fingerGestures gameObject loaded success!!");
|
|
}
|
|
else
|
|
{
|
|
//FLogger.Log("fingerGestures gameObject loaded fail!", GetResPath());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region//私有方法
|
|
//获取资源的路径
|
|
private string GetResPath()
|
|
{
|
|
#if !UNITY_EDITOR && (UNITY_IPHONE || UNITY_ANDROID)
|
|
return _prefab_TouchScreenGestures;
|
|
#else
|
|
return _prefab_MouseGestures;
|
|
#endif
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|