This repository has been archived by the owner on Jan 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Juce-Assets/develop
- Loading branch information
Showing
13 changed files
with
252 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Juce.Utils.Singletons; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Juce.Feedbacks | ||
{ | ||
public class JuceFeedbacks : AutoStartMonoSingleton<JuceFeedbacks> | ||
{ | ||
private readonly Dictionary<string, FeedbacksPlayer> feedbackPlayersUsedByScript = new Dictionary<string, FeedbacksPlayer>(); | ||
|
||
internal bool RegisterFeedbacksPlayerUsedByScript(FeedbacksPlayer feedbacksPlayer) | ||
{ | ||
if (!feedbacksPlayer.ScriptUsage.UsedByScript) | ||
{ | ||
return false; | ||
} | ||
|
||
if (string.IsNullOrEmpty(feedbacksPlayer.ScriptUsage.IdUsedByScript)) | ||
{ | ||
UnityEngine.Debug.LogError($"Trying to register a {nameof(FeedbacksPlayer)}, but the Id Used By Script is empty. " + | ||
$"Please set an id or untoggle Used By Script.", feedbacksPlayer); | ||
|
||
return false; | ||
} | ||
|
||
if (feedbackPlayersUsedByScript.ContainsKey(feedbacksPlayer.ScriptUsage.IdUsedByScript)) | ||
{ | ||
UnityEngine.Debug.LogError($"Trying to register a {nameof(FeedbacksPlayer)}, but the Id Used By Script " + | ||
$"'{feedbacksPlayer.ScriptUsage.IdUsedByScript}' is already used by " + | ||
$"another {nameof(FeedbacksPlayer)}. Please set an Id Used By Script that's unique.", feedbacksPlayer); | ||
|
||
return false; | ||
} | ||
|
||
feedbackPlayersUsedByScript.Add(feedbacksPlayer.ScriptUsage.IdUsedByScript, feedbacksPlayer); | ||
|
||
return true; | ||
} | ||
|
||
internal void UnregisterFeedbacksPlayerUsedByScript(string id) | ||
{ | ||
feedbackPlayersUsedByScript.Remove(id); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the <typeparamref name="FeedbacksPlayer"/> found, which has the Used By Script toggled, and the Id Used By Script defined on the editor. | ||
/// Returns null if not found. | ||
/// </summary> | ||
public static FeedbacksPlayer GetFeedbacksPlayer(string id) | ||
{ | ||
Instance.feedbackPlayersUsedByScript.TryGetValue(id, out FeedbacksPlayer feedbacksPlayer); | ||
|
||
return feedbacksPlayer; | ||
} | ||
|
||
/// <summary> | ||
/// Outs the <typeparamref name="FeedbacksPlayer"/> found, which has the Used By Script toggled, and the Id Used By Script defined on the editor. | ||
/// Returns false if not found. | ||
/// </summary> | ||
public static bool TryGetFeedbacksPlayer(string id, out FeedbacksPlayer feedbacksPlayer) | ||
{ | ||
return Instance.feedbackPlayersUsedByScript.TryGetValue(id, out feedbacksPlayer); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters