Initialer Upload neues Unity-Projekt

This commit is contained in:
Daniel Ocks
2025-07-21 09:11:14 +02:00
commit eeca72985b
14558 changed files with 1508140 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#if UNITY_EDITOR
using UnityEditor.EditorTools;
#endif
using UnityEditor;
using UnityEngine;
namespace Convai.Scripts.Runtime.Utils
{
/// <summary>
/// ScriptableObject that stores Convai API Key.
/// Allows the API key to be easily changed from the Unity editor and reduces risk of embedding keys directly into
/// script.
/// This object can be created from Unity Editor by going in top menu to Convai -> API Key
/// </summary>
[CreateAssetMenu(fileName = "ConvaiAPIKey", menuName = "Convai/API Key")]
public class ConvaiAPIKeySetup : ScriptableObject
{
[ReadOnly] public string APIKey;
private static bool hasShownDialog = false;
public static bool GetAPIKey(out string apiKey)
{
ConvaiAPIKeySetup keySetup = Resources.Load<ConvaiAPIKeySetup>("ConvaiAPIKey");
if (keySetup == null)
{
#if UNITY_EDITOR
if (!hasShownDialog)
{
// display editor utility to show a dialog box saying no API Key found
EditorUtility.DisplayDialog("Error", "Convai API Key not found. Please add your API Key by going to Convai -> Convai Setup", "OK");
hasShownDialog = true;
}
#endif
if (NotificationSystemHandler.Instance != null)
{
NotificationSystemHandler.Instance.NotificationRequest(NotificationType.APIKeyNotFound);
}
apiKey = string.Empty;
return false;
}
apiKey = keySetup.APIKey;
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3402f41fb2bc77540b1edc3e8db81bce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Convai.Scripts.Utils
{
public class MainThreadDispatcher : MonoBehaviour
{
private readonly Queue<Action> _actions = new();
public static MainThreadDispatcher Instance { get; private set; }
private void Update()
{
lock (_actions)
{
while (_actions.Count > 0)
{
Action actionToInvoke = _actions.Dequeue();
actionToInvoke?.Invoke();
}
}
}
public static void CreateInstance()
{
Instance = new GameObject("MainThreadDispatcher").AddComponent<MainThreadDispatcher>();
DontDestroyOnLoad(Instance.gameObject);
}
public void RunOnMainThread(Action action)
{
lock (_actions)
{
_actions.Enqueue(action);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b162b45e89a36d4ba0b404191517ebb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: