//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, October 12, 2017
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
|
namespace vnxbqy.UI
|
{
|
|
public class UI3DTreasureExhibition : MonoBehaviour
|
{
|
const string EFFECT_BONE = "Bone_effect";
|
|
[SerializeField] Transform m_ShowPoint;
|
[SerializeField] Camera m_ShowCamera;
|
|
//法宝
|
int m_TreasureId = 0;
|
GameObject treasureModel = null;
|
SFXController effect;
|
|
//法器
|
string m_FaqiPathName;
|
string m_FaqiModelName;
|
GameObject faqiModel = null;
|
|
GameObject weaponModel = null;
|
int m_GodWeaponType = 0;
|
|
static UI3DTreasureExhibition m_Instance = null;
|
public static UI3DTreasureExhibition Instance {
|
get {
|
if (m_Instance == null)
|
{
|
var gameObject = Instantiate(BuiltInLoader.LoadPrefab("UI3DTreasureExhibitionStage"));
|
m_Instance = gameObject.GetComponent<UI3DTreasureExhibition>();
|
Instance.transform.position = new Vector3(0, 2000, 3000);
|
m_Instance.name = "UI3DTreasureExhibitionStage";
|
m_Instance.SetActive(true);
|
m_Instance.m_ShowCamera.enabled = false;
|
DontDestroyOnLoad(gameObject);
|
}
|
|
return m_Instance;
|
}
|
}
|
|
|
public void ShowFaQiModel(string pathName, string modelName, RawImage _rawImage, int effectID)
|
{
|
var instance = UI3DModelFactory.LoadUIFaqi(pathName, modelName);
|
if (instance == null)
|
{
|
return;
|
}
|
|
Stop();
|
|
m_ShowCamera.enabled = true;
|
m_FaqiPathName = pathName;
|
m_FaqiModelName = modelName;
|
faqiModel = instance;
|
instance.transform.SetParentEx(m_ShowPoint, Vector3.zero, Quaternion.identity, Vector3.one);
|
instance.SetActive(true);
|
|
var fbPoint = faqiModel.transform.GetChildTransformDeeply(EFFECT_BONE);
|
if (fbPoint == null)
|
{
|
fbPoint = faqiModel.transform;
|
}
|
|
effect = SFXPlayUtility.Instance.Play(effectID, fbPoint);
|
if (effect != null)
|
{
|
LayerUtility.SetLayer(effect.gameObject, LayerUtility.UILayer, true);
|
}
|
|
if (_rawImage != null)
|
{
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
}
|
}
|
|
|
public void ShowTreasure(int _treasureId, RawImage _rawImage)
|
{
|
var instance = UI3DModelFactory.LoadUITreasure(_treasureId);
|
if (instance == null)
|
{
|
return;
|
}
|
|
Stop();
|
|
m_ShowCamera.enabled = true;
|
m_TreasureId = _treasureId;
|
treasureModel = instance;
|
|
var config = TreasureConfig.Get(_treasureId);
|
|
var scale = (config == null || config.UIScale == 0) ? 100 : config.UIScale;
|
instance.transform.SetParentEx(m_ShowPoint, Vector3.zero, Quaternion.identity, Vector3.one * ((float)scale / 100));
|
instance.SetActive(true);
|
|
var mountPoint = treasureModel.transform.GetChildTransformDeeply(EFFECT_BONE);
|
if (mountPoint == null)
|
{
|
mountPoint = treasureModel.transform;
|
}
|
|
effect = SFXPlayUtility.Instance.Play(config.EffectID, mountPoint);
|
if (effect != null)
|
{
|
LayerUtility.SetLayer(effect.gameObject, LayerUtility.UILayer, true);
|
}
|
|
if (_rawImage != null)
|
{
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
}
|
}
|
|
public void ShowGodWeapon(int _type, RawImage _rawImage)
|
{
|
var instance = UI3DModelFactory.LoadUIGodWeapon(_type);
|
if (instance == null)
|
{
|
return;
|
}
|
|
Stop();
|
|
m_ShowCamera.enabled = true;
|
m_GodWeaponType = _type;
|
weaponModel = instance;
|
instance.transform.SetParentEx(m_ShowPoint, Vector3.zero, Quaternion.identity, Vector3.one);
|
instance.SetActive(true);
|
|
if (_rawImage != null)
|
{
|
_rawImage.texture = m_ShowCamera.targetTexture;
|
_rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
|
}
|
}
|
|
public void Stop()
|
{
|
m_ShowCamera.enabled = false;
|
if (effect != null)
|
{
|
SFXPlayUtility.Instance.Release(effect);
|
effect = null;
|
}
|
|
if (weaponModel != null)
|
{
|
UI3DModelFactory.ReleaseUIGodWeapon(m_GodWeaponType, weaponModel);
|
weaponModel = null;
|
m_GodWeaponType = 0;
|
}
|
|
if (treasureModel != null)
|
{
|
UI3DModelFactory.ReleaseUITreasure(m_TreasureId, treasureModel);
|
treasureModel = null;
|
m_TreasureId = 0;
|
}
|
|
if (faqiModel != null)
|
{
|
UI3DModelFactory.ReleaseUIFaqi(m_FaqiPathName, m_FaqiModelName, faqiModel);
|
faqiModel = null;
|
m_FaqiPathName = string.Empty;
|
m_FaqiModelName = string.Empty;
|
}
|
}
|
|
private void Awake()
|
{
|
OnQualityChange();
|
SystemSetting.Instance.qualityLevelChangeEvent += OnQualityChange;
|
}
|
|
private void OnDestroy()
|
{
|
SystemSetting.Instance.qualityLevelChangeEvent -= OnQualityChange;
|
}
|
|
private void OnQualityChange()
|
{
|
}
|
|
}
|
|
}
|
|
|
|