| | |
| | | |
| | | public static bool allFromEditor {
|
| | | get {
|
| | | return audioFromEditor && effectFromEditor && mobFromEditor && refdataFromEditor && sceneFromEditor && shaderFromEditor && uiFromEditor;
|
| | | return audioFromEditor
|
| | | && effectFromEditor
|
| | | && mobFromEditor
|
| | | && refdataFromEditor
|
| | | && sceneFromEditor
|
| | | && shaderFromEditor
|
| | | && uiFromEditor
|
| | | && builtInFromEditor;
|
| | | }
|
| | | set {
|
| | | audioFromEditor = value;
|
| | |
| | | shaderFromEditor = value;
|
| | | sceneFromEditor = value;
|
| | | uiFromEditor = value;
|
| | | builtInFromEditor = value;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | m_UIFromEditor=value;
|
| | | #endif
|
| | | }
|
| | | }
|
| | |
|
| | | static bool m_BuiltInFromEditor = false;
|
| | | public static bool builtInFromEditor {
|
| | | get {
|
| | | #if UNITY_EDITOR
|
| | | return LocalSave.GetBool("Asset_BuiltInFromEditor", true);
|
| | | #else
|
| | | return false;
|
| | | #endif
|
| | | }
|
| | | set {
|
| | | #if UNITY_EDITOR
|
| | | LocalSave.SetBool("Asset_BuiltInFromEditor", value);
|
| | | #else
|
| | | m_BuiltInFromEditor=value;
|
| | | #endif
|
| | | }
|
| | | } |
| | | |
| | | } |
| | |
| | | EditorApplication.delayCall += ExcuteBuildUI;
|
| | | }
|
| | |
|
| | | if (GUILayout.Button("BuiltIn"))
|
| | | {
|
| | | EditorApplication.delayCall += ExcuteBuildBuiltIn;
|
| | | }
|
| | |
|
| | | if (GUILayout.Button("Audio"))
|
| | | {
|
| | | EditorApplication.delayCall += ExcuteBuildAudio;
|
| | |
| | | AssetBundleBuildExtersion.Build(outputPath, _category, opt, (BuildTarget)m_UserData.m_BuildTarget);
|
| | | }
|
| | |
|
| | | private void ExcuteBuildBuiltIn()
|
| | | {
|
| | | ExcuteBuildAsset("builtin");
|
| | | }
|
| | |
|
| | | private void ExcuteBuildAudio()
|
| | | {
|
| | | UpdateAudioSetting.SetAllAudioAssetBundleName();
|
| | |
| | | {
|
| | | UpdateScriptableObjectsSetting.SetAllScriptableObjectAssetBundleName();
|
| | | ExcuteBuildAsset("config");
|
| | | TableTool.ReadAllTxtToBytes(StringUtility.Contact(m_UserData.m_OutputPath, "/config"));
|
| | | TableTool.CopyConfigsToOutPutPath(StringUtility.Contact(m_UserData.m_OutputPath, "/config"));
|
| | | }
|
| | |
|
| | | private void ExcuteBuildLevels()
|
| | |
| | | switch (_assetPath)
|
| | | {
|
| | | case AssetPath.Resource:
|
| | | path = StringUtility.Contact("Config/", fileName);
|
| | | var textAsset = Resources.Load<TextAsset>(path);
|
| | | lines = textAsset.text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
|
| | | path = AssetVersionUtility.GetAssetFilePath(StringUtility.Contact("config/", fileName, ".txt"));
|
| | | if (File.Exists(path))
|
| | | {
|
| | | lines = File.ReadAllLines(path, Encoding.UTF8);
|
| | | }
|
| | | else
|
| | | {
|
| | | path = StringUtility.Contact("Config/", fileName);
|
| | | var textAsset = Resources.Load<TextAsset>(path);
|
| | | lines = textAsset.text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
|
| | | }
|
| | | break;
|
| | | case AssetPath.ResourceOut:
|
| | | path = StringUtility.Contact(ResourcesPath.CONFIG_FODLER, "/", fileName, ".txt");
|
| New file |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | |
| | | public class BuiltInLoader |
| | | { |
| | | readonly static string PREFAB_EXTENSION = ".prefab"; |
| | | readonly static string SPRITE_EXTENSION = ".png"; |
| | | readonly static string AUDIO_EXTENSION = ".wav"; |
| | | |
| | | public static Sprite LoadSprite(string name) |
| | | { |
| | | Sprite sprite = null; |
| | | if (AssetSource.builtInFromEditor) |
| | | { |
| | | #if UNITY_EDITOR |
| | | var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/UI/Sprites/", name, SPRITE_EXTENSION); |
| | | sprite = UnityEditor.AssetDatabase.LoadAssetAtPath<Sprite>(path); |
| | | #endif |
| | | } |
| | | else |
| | | { |
| | | var assetInfo = new AssetInfo("builtin", name); |
| | | sprite = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo, typeof(Sprite)) as Sprite; |
| | | } |
| | | |
| | | if (sprite == null) |
| | | { |
| | | DebugEx.LogErrorFormat("BuiltInLoader.LoadSprite() => 加载不到资源: {0}.", name); |
| | | } |
| | | |
| | | return sprite; |
| | | } |
| | | |
| | | public static GameObject LoadPrefab(string name) |
| | | { |
| | | GameObject prefab = null; |
| | | if (AssetSource.builtInFromEditor) |
| | | { |
| | | #if UNITY_EDITOR |
| | | var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/UI/Prefabs/", name, PREFAB_EXTENSION); |
| | | prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path); |
| | | #endif |
| | | } |
| | | else |
| | | { |
| | | var assetInfo = new AssetInfo("builtin", name); |
| | | prefab = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject; |
| | | } |
| | | |
| | | if (prefab == null) |
| | | { |
| | | DebugEx.LogErrorFormat("BuiltInLoader.LoadPrefab() => 加载不到资源: {0}.", name); |
| | | } |
| | | |
| | | return prefab; |
| | | } |
| | | |
| | | public static void UnLoadPrefab(string name) |
| | | { |
| | | if (!AssetSource.builtInFromEditor) |
| | | { |
| | | AssetBundleUtility.Instance.UnloadAsset("builtin", name); |
| | | } |
| | | } |
| | | |
| | | public static AudioClip LoadMusic(string name) |
| | | { |
| | | AudioClip audioClip = null; |
| | | if (AssetSource.builtInFromEditor) |
| | | { |
| | | #if UNITY_EDITOR |
| | | var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/Music/", name, AUDIO_EXTENSION); |
| | | audioClip = UnityEditor.AssetDatabase.LoadAssetAtPath<AudioClip>(path); |
| | | #endif |
| | | } |
| | | else |
| | | { |
| | | var assetInfo = new AssetInfo("builtin", name); |
| | | audioClip = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as AudioClip; |
| | | } |
| | | |
| | | if (audioClip == null) |
| | | { |
| | | DebugEx.LogErrorFormat("BuiltInLoader.LoadMusic() => 加载不到资源: {0}.", name); |
| | | } |
| | | |
| | | return audioClip; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 90d4474ca18a3f641af2abaf246763e2 |
| | | timeCreated: 1540434103 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| | |
| | | [SerializeField] Toggle m_Refdata; |
| | | [SerializeField] Toggle m_Shader; |
| | | [SerializeField] Toggle m_UI; |
| | | [SerializeField] Toggle m_BuiltIn; |
| | | |
| | | private void OnEnable() |
| | | { |
| | |
| | | m_Refdata.isOn = AssetSource.refdataFromEditor; |
| | | m_Shader.isOn = AssetSource.shaderFromEditor; |
| | | m_UI.isOn = AssetSource.uiFromEditor; |
| | | m_BuiltIn.isOn = AssetSource.builtInFromEditor; |
| | | |
| | | m_AllAsset.AddListener(OnAllAssetValueChange); |
| | | m_Audio.AddListener(OnAudioValueChange); |
| | |
| | | m_Refdata.AddListener(OnRefdataValueChange); |
| | | m_Shader.AddListener(OnShaderValueChange); |
| | | m_UI.AddListener(OnUIValueChange); |
| | | m_BuiltIn.AddListener(OnBuildInValueChange); |
| | | } |
| | | |
| | | private void OnDisable() |
| | |
| | | AssetSource.uiFromEditor = _value; |
| | | } |
| | | |
| | | private void OnBuildInValueChange(bool _value) |
| | | { |
| | | AssetSource.builtInFromEditor = _value; |
| | | } |
| | | |
| | | } |
| | |
| | | {
|
| | | if (debugRoot == null)
|
| | | {
|
| | | var prefab = Resources.Load<GameObject>("UI/Prefabs/UIRootDebug");
|
| | | var prefab = BuiltInLoader.LoadPrefab("UIRootDebug");
|
| | | debugRoot = GameObject.Instantiate(prefab);
|
| | | MonoBehaviour.DontDestroyOnLoad(debugRoot);
|
| | | debugRoot.name = "UIRootDebug";
|
| | |
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | var sprite = Resources.Load<Sprite>("UI/Sprites/LoginBackGround");
|
| | | var sprite = BuiltInLoader.LoadSprite("LoginBackGround");
|
| | | useStaticBackGround = sprite != null;
|
| | |
|
| | | if (useStaticBackGround)
|
| | |
| | | #region Built-in
|
| | | protected override void BindController()
|
| | | {
|
| | | var sprite = Resources.Load<Sprite>("UI/Sprites/Launch");
|
| | | var sprite = BuiltInLoader.LoadSprite("Launch");
|
| | | m_BackGround.overrideSprite = sprite;
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | m_BanHao.text = string.IsNullOrEmpty(VersionConfig.Get().banHao) ? string.Empty : VersionConfig.Get().banHao;
|
| | |
|
| | | var sprite = Resources.Load<Sprite>("UI/Sprites/TB_DL_Logo");
|
| | | var sprite = BuiltInLoader.LoadSprite("TB_DL_Logo");
|
| | | m_Logo.overrideSprite = sprite;
|
| | | m_Logo.SetNativeSize();
|
| | | m_Logo.rectTransform.anchoredPosition = VersionConfig.Get().logoPosition;
|
| | |
| | | get {
|
| | | if (m_UIRoot == null)
|
| | | {
|
| | | var prefab = Resources.Load<GameObject>("UI/Prefabs/UIRoot");
|
| | | var prefab = BuiltInLoader.LoadPrefab("UIRoot");
|
| | | var instance = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity);
|
| | | instance.name = "UIRoot";
|
| | | m_UIRoot = instance.GetComponent<UIRoot>();
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | var prefab = _fromLocal ? Resources.Load<GameObject>(StringUtility.Contact("UI/Prefabs/", prefabName)) : UILoader.LoadWindow(prefabName);
|
| | | var prefab = _fromLocal ? BuiltInLoader.LoadPrefab(prefabName) : UILoader.LoadWindow(prefabName);
|
| | | prefab.SetActive(false);
|
| | | var instance = GameObject.Instantiate(prefab);
|
| | | if (AssetSource.uiFromEditor)
|
| | |
| | | prefab.SetActive(true);
|
| | | }
|
| | |
|
| | | UILoader.UnLoadWindowAsset(prefabName);
|
| | | if (_fromLocal)
|
| | | {
|
| | | BuiltInLoader.UnLoadPrefab(prefabName);
|
| | | }
|
| | | else
|
| | | {
|
| | | UILoader.UnLoadWindowAsset(prefabName);
|
| | | }
|
| | |
|
| | | instance.name = prefabName;
|
| | | var window = instance.GetComponent<T>();
|
| | | if (window != null)
|
| | |
| | | var uiroot = GameObject.FindObjectOfType<UIRoot>();
|
| | | if (uiroot == null)
|
| | | {
|
| | | var prefab = Resources.Load<GameObject>("UI/Prefabs/UIRoot");
|
| | | var prefab = BuiltInLoader.LoadPrefab("UIRoot");
|
| | | var instance = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity);
|
| | | instance.name = "UIRoot";
|
| | | uiroot = instance.GetComponent<UIRoot>();
|
| | |
| | |
|
| | | public static void CreateStage()
|
| | | {
|
| | | var prefab = Resources.Load<GameObject>("UI/Prefabs/UI3DModelExhibitionStage");
|
| | | var prefab = BuiltInLoader.LoadPrefab("UI3DModelExhibitionStage");
|
| | | var gameObject = GameObject.Instantiate(prefab);
|
| | | Instance = gameObject.GetComponent<UI3DModelExhibition>();
|
| | | Instance.transform.position = new Vector3(1000, 2000, 3000);
|
| | |
| | |
|
| | | static void CreateCloneStage()
|
| | | {
|
| | | var prefab = Resources.Load<GameObject>("UI/Prefabs/UI3DModelExhibitionStage");
|
| | | var prefab = BuiltInLoader.LoadPrefab("UI3DModelExhibitionStage");
|
| | | var gameObject = GameObject.Instantiate(prefab);
|
| | | m_InstanceClone1 = gameObject.GetComponent<UI3DModelExhibition>();
|
| | | m_InstanceClone1.transform.position = new Vector3(2000, 4000, 5000);
|
| | |
| | | get {
|
| | | if (m_Instance == null)
|
| | | {
|
| | | var gameObject = Instantiate(Resources.Load<GameObject>("UI/Prefabs/UI3DTreasureExhibitionStage"));
|
| | | var gameObject = Instantiate(BuiltInLoader.LoadPrefab("UI3DTreasureExhibitionStage"));
|
| | | m_Instance = gameObject.GetComponent<UI3DTreasureExhibition>();
|
| | | Instance.transform.position = new Vector3(0, 2000, 3000);
|
| | | m_Instance.name = "UI3DTreasureExhibitionStage";
|
| | |
| | | { |
| | | if (hudRoot == null) |
| | | { |
| | | var prefab = Resources.Load<GameObject>("UI/Prefabs/HUDRoot"); |
| | | var prefab = BuiltInLoader.LoadPrefab("HUDRoot"); |
| | | var instance = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity); |
| | | instance.name = "HUDRoot"; |
| | | hudRoot = instance.GetComponent<HUDRoot>(); |