Skip to content

Commit

Permalink
updated to v2.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
michael811125 committed Nov 7, 2024
1 parent bc98b5e commit c3ad324
Show file tree
Hide file tree
Showing 23 changed files with 298 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public static void SwitchDefaultPackage(string packageName)
_currentPackageName = package.PackageName;
_currentPackage = package;
}
else Logging.Print<Logger>($"<color=#ff2478>Switch default package failed! Cannot found package: {packageName}.</color>");
else Logging.Print<Logger>($"<color=#ff2478>Switch default package failed! Cannot find package: {packageName}.</color>");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private async UniTask _AppVersionComparison(AppConfig hostCfg)
}
else
{
Logging.Print<Logger>("<color=#FF0000>Cannot found bundle config from StreamingAssets.</color>");
Logging.Print<Logger>("<color=#FF0000>Cannot find bundle config from StreamingAssets.</color>");
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public static async UniTask RequestAndCopyFileFromStreamingAssets(string sourceF

if (request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
{
Logging.Print<Logger>("<color=#FF0000>Request failed. Cannot found file in StreamingAssets.</color>");
Logging.Print<Logger>("<color=#FF0000>Request failed. Cannot find file in StreamingAssets.</color>");
Logging.Print<Logger>(request.error);
}
else
Expand Down
70 changes: 70 additions & 0 deletions Assets/OxGFrame/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,75 @@
# CHANGELOG

## [2.12.1] - 2024-11-08
- Added MediaFrame (Audio, Video) with an option to specify a sourceClip, handled by the prefab container for playback.
```csharp
// Audio
public static async UniTask<AudioBase> Play(string assetName, AudioClip sourceClip, Transform parent = null, int loops = 0, float volume = 0f)
public static async UniTask<AudioBase> Play(string packageName, string assetName, AudioClip sourceClip, Transform parent = null, int loops = 0, float volume = 0f)

// Video
public static async UniTask<VideoBase> Play(string assetName, VideoClip sourceClip, Transform parent = null, int loops = 0, float volume = 0f)
public static async UniTask<VideoBase> Play(string packageName, string assetName, VideoClip sourceClip, Transform parent = null, int loops = 0, float volume = 0f)
```
- Added CoreFrame binding parameters that will compare with the parent class's binding parameters and remove any overlapping parts.
```csharp
TestAUI ↓↓↓

#region Binding Components
[HideInInspector] public GameObject a;
protected GameObject _b;

/// <summary>
/// Auto Binding Section
/// </summary>
protected override void OnAutoBind()
{
base.OnAutoBind();
this.a = this.collector.GetNode("A");
this._b = this.collector.GetNode("B");
}
#endregion

TestBUI : TestAUI ↓↓↓
#region Binding Components
protected ButtonPlus _cBtnPlus;

/// <summary>
/// Auto Binding Section
/// </summary>
protected override void OnAutoBind()
{
base.OnAutoBind();
this._cBtnPlus = this.collector.GetNodeComponent<ButtonPlus>("C*BtnPlus");
}
#endregion

TestCUI : TestBUI ↓↓↓
#region Binding Components
protected GameObject _d;

/// <summary>
/// Auto Binding Section
/// </summary>
protected override void OnAutoBind()
{
base.OnAutoBind();
this._d = this.collector.GetNode("D");
}
#endregion
```
- Added some methods to CoreFrames.USFrame.
```csharp
public static Scene CreateScene(string sceneName, CreateSceneParameters parameters)
public static bool MergeScenes(Scene sourceScene, Scene targetScene)
public static bool MoveGameObjectToScene(GameObject go, Scene targetScene)
public static bool MoveGameObjectToActiveScene(GameObject go)
```
- Modified the CoreFrame Attrs binding format to a single-line format.
- Modified the configuration file’s default value from 127.0.0.1 to http://127.0.0.1.
- Fixed handling for MediaFrame when the clip is null.
- Fixed an issue in which the CoreFrame object returned Null when calling Show on an already showing object. It now returns the cached object instead.

## [2.12.0] - 2024-10-24 (rule changed)
- Modified CloseAll, HideAll, RevealAll rules of method for UIFrame and SRFrame.
- Set the default group id to 0, but if you don't want to execute based on the group id and want to do all, can set the group id to -1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected TClass GetFromCache(int id)
{
if (!this.HasInCache(id))
{
Logging.Print<Logger>(string.Format("<color=#FF0000>Cannot found. Id: {0}</color>", id));
Logging.Print<Logger>(string.Format("<color=#FF0000>Cannot find. Id: {0}</color>", id));
return default;
}

Expand Down
32 changes: 32 additions & 0 deletions Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/CoreFrames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public static class CoreFrames
/// </summary>
internal const int DEFAULT_GROUP_ID = 0;

/// <summary>
/// User Interface
/// </summary>
public static class UIFrame
{
public static bool ignoreTimeScale
Expand Down Expand Up @@ -377,6 +380,9 @@ public static void HideAllAndExcluded(int groupId, params string[] withoutAssetN
#endregion
}

/// <summary>
/// Scene Resource
/// </summary>
public static class SRFrame
{
public static bool ignoreTimeScale
Expand Down Expand Up @@ -684,6 +690,9 @@ public static void HideAllAndExcluded(int groupId, params string[] withoutAssetN
#endregion
}

/// <summary>
/// Unity Scene
/// </summary>
public static class USFrame
{
public static void InitInstance()
Expand All @@ -696,6 +705,26 @@ public static int SceneCount()
return USManager.sceneCount;
}

public static Scene CreateScene(string sceneName, CreateSceneParameters parameters)
{
return USManager.GetInstance().CreateScene(sceneName, parameters);
}

public static bool MergeScenes(Scene sourceScene, Scene targetScene)
{
return USManager.GetInstance().MergeScenes(sourceScene, targetScene);
}

public static bool MoveGameObjectToScene(GameObject go, Scene targetScene)
{
return USManager.GetInstance().MoveGameObjectToScene(go, targetScene);
}

public static bool MoveGameObjectToActiveScene(GameObject go)
{
return USManager.GetInstance().MoveGameObjectToActiveScene(go);
}

public static Scene GetActiveScene()
{
return USManager.GetInstance().GetActiveScene();
Expand Down Expand Up @@ -1413,6 +1442,9 @@ internal static bool RefineBuildScenePath(ref string sceneName)
}
}

/// <summary>
/// Clone Prefab
/// </summary>
public static class CPFrame
{
public static void InitInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OxGFrame.AssetLoader;
using OxGFrame.AssetLoader.Cacher;
using OxGKit.LoggingSystem;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
Expand Down Expand Up @@ -35,6 +36,54 @@ public static USManager GetInstance()
return _instance;
}

public Scene CreateScene(string sceneName, CreateSceneParameters parameters)
{
return SceneManager.CreateScene(sceneName, parameters);
}

public bool MergeScenes(Scene sourceScene, Scene targetScene)
{
try
{
SceneManager.MergeScenes(sourceScene, targetScene);
return true;
}
catch (Exception ex)
{
Logging.PrintException<Logger>(ex);
return false;
}
}

public bool MoveGameObjectToScene(GameObject go, Scene targetScene)
{
try
{
SceneManager.MoveGameObjectToScene(go, targetScene);
return true;
}
catch (Exception ex)
{
Logging.PrintException<Logger>(ex);
return false;
}
}

public bool MoveGameObjectToActiveScene(GameObject go)
{
try
{
Scene targetScene = this.GetActiveScene();
SceneManager.MoveGameObjectToScene(go, targetScene);
return true;
}
catch (Exception ex)
{
Logging.PrintException<Logger>(ex);
return false;
}
}

public Scene GetActiveScene()
{
return SceneManager.GetActiveScene();
Expand Down
2 changes: 1 addition & 1 deletion Assets/OxGFrame/GSIFrame/Scripts/Runtime/GSIManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ protected void InitGameStage()
// 開始進行 GameStage 初始流程
if (this._currentGameStage != null) this._currentGameStage.BeginInit().Forget();
#if UNITY_EDITOR
else Logging.Print<Logger>(string.Format("Cannot found GameStage. Id: {0}", this._currentId));
else Logging.Print<Logger>(string.Format("Cannot find GameStage. Id: {0}", this._currentId));
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected virtual async void DrawAudioLengthView()
case SourceType.Audio:
audioClip = this._target.audioClip;
if (audioClip != null) this._audioLength.floatValue = this._target.audioLength = this._target.audioClip.length;
else Debug.LogError("Cannot found AudioClip");
else Debug.LogError("Cannot find AudioClip");
break;

case SourceType.StreamingAssets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ public class AudioBase : MediaBase
[SerializeField, ConditionalField(nameof(_mixerGroupSourceType), false, MixerGroupSourceType.Find)]
protected string _mixerGroupName = "";

public override async UniTask Init()
public override async UniTask<bool> Init()
{
this._audioSource = this.GetComponent<AudioSource>();
await this._InitAudio();
bool isInitialized = await this._InitAudio();

this._isInit = true; // Mark all init is finished.
if (isInitialized)
this._isInit = true; // Mark all init is finished.

return this._isInit;
}

private async UniTask _InitAudio()
private async UniTask<bool> _InitAudio()
{
this.isPrepared = false;

if (this._audioSource == null) return;
if (this._audioSource == null)
return false;

// Get Audio
switch (this.sourceType)
Expand All @@ -66,8 +70,8 @@ private async UniTask _InitAudio()

if (this.audioClip == null)
{
Logging.Print<Logger>($"<color=#FF0000>Cannot found AudioClip: {this.mediaName}</color>");
return;
Logging.Print<Logger>($"<color=#FF0000>Cannot find AudioClip: {this.mediaName}</color>");
return false;
}

// Get Mixer Group
Expand All @@ -93,6 +97,8 @@ private async UniTask _InitAudio()
this.isPrepared = true;

Logging.Print<Logger>($"<color=#00EEFF>【Init Once】 Audio length: {this._mediaLength} (s)</color>");

return this.isPrepared;
}

public async UniTask<AudioClip> GetAudioFromStreamingAssets(bool cached)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static AudioManager GetInstance()
lock (_locker)
{
_instance = FindObjectOfType<AudioManager>();
if (_instance == null) Logging.PrintWarning<Logger>("<color=#FF0000>Cannot found 【AudioManager Component】, Please to check your 【AudioManager GameObject】.</color>");
if (_instance == null) Logging.PrintWarning<Logger>("<color=#FF0000>Cannot find 【AudioManager Component】, Please to check your 【AudioManager GameObject】.</color>");
}
}
return _instance;
Expand Down Expand Up @@ -393,9 +393,9 @@ private void _Play(AudioBase audBase, int loops, float volume)
/// <param name="parent"></param>
/// <param name="loops"></param>
/// <returns></returns>
public override async UniTask<AudioBase[]> Play(string packageName, string assetName, Transform parent = null, int loops = 0, float volume = 0f)
public override async UniTask<AudioBase[]> Play(string packageName, string assetName, UnityEngine.Object sourceClip, Transform parent = null, int loops = 0, float volume = 0f)
{
if (string.IsNullOrEmpty(assetName)) return new AudioBase[] { };
if (string.IsNullOrEmpty(assetName)) return new AudioBase[] { null };

AudioBase[] audBases = this.GetMediaComponents<AudioBase>(assetName);
bool isResume = false;
Expand All @@ -420,11 +420,11 @@ public override async UniTask<AudioBase[]> Play(string packageName, string asset
GameObject go = await this.LoadAssetIntoCache(packageName, assetName);
Transform spawnParent = null;
if (parent == null) spawnParent = this.transform;
AudioBase audBase = await this.CloneAsset<AudioBase>(assetName, go, parent, spawnParent);
AudioBase audBase = await this.CloneAsset<AudioBase>(assetName, go, sourceClip, parent, spawnParent);
if (audBase == null)
{
Logging.PrintWarning<Logger>(string.Format("Asset not found at this path!!!【Audio】: {0}", assetName));
return new AudioBase[] { };
return new AudioBase[] { null };
}

this._Play(audBase, loops, volume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal void HandleFixedUpdate(float dt)
/// <summary>
/// 初始用
/// </summary>
public abstract UniTask Init();
public abstract UniTask<bool> Init();

/// <summary>
/// 固定每幀被調用
Expand Down
Loading

0 comments on commit c3ad324

Please sign in to comment.