upgrade CCK to v3.5

This commit is contained in:
Crispy 2023-07-30 01:20:46 +02:00
parent 6fe98b333d
commit 3005cfc8aa
43 changed files with 1213 additions and 289 deletions

View file

@ -0,0 +1,353 @@
using System;
using System.Collections.Generic;
using ABI.CCK.Components;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using AnimatorController = UnityEditor.Animations.AnimatorController;
using AnimatorControllerParameterType = UnityEngine.AnimatorControllerParameterType;
[CustomEditor(typeof(ABI.CCK.Components.AnimatorDriver))]
public class CCK_AnimatorDriverEditor : UnityEditor.Editor
{
private AnimatorDriver _animatorDriver;
private ReorderableList _onEnterList;
private ReorderableList _onExitList;
private List<string> animatorParamNames = new List<string>();
private List<string> animatorParamNamesDisplay = new List<string>();
private List<AnimatorDriverTask.ParameterType> animatorParamTypes = new List<AnimatorDriverTask.ParameterType>();
public override void OnInspectorGUI()
{
if (_animatorDriver == null) _animatorDriver = (AnimatorDriver) target;
animatorParamNames.Clear();
animatorParamNamesDisplay.Clear();
animatorParamTypes.Clear();
animatorParamNames.Add("- None -");
animatorParamNamesDisplay.Add("- None -");
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.None);
var behaviorContext = AnimatorController.FindStateMachineBehaviourContext(_animatorDriver);
if (behaviorContext.Length > 0)
{
var controller = behaviorContext[0].animatorController;
foreach (var parameter in controller.parameters)
{
switch (parameter.type)
{
case AnimatorControllerParameterType.Bool:
animatorParamNames.Add($"{parameter.name}");
animatorParamNamesDisplay.Add($"{parameter.name} (Bool)");
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Bool);
break;
case AnimatorControllerParameterType.Float:
animatorParamNames.Add($"{parameter.name}");
animatorParamNamesDisplay.Add($"{parameter.name} (Float)");
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Float);
break;
case AnimatorControllerParameterType.Int:
animatorParamNames.Add($"{parameter.name}");
animatorParamNamesDisplay.Add($"{parameter.name} (Int)");
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Int);
break;
case AnimatorControllerParameterType.Trigger:
animatorParamNames.Add($"{parameter.name}");
animatorParamNamesDisplay.Add($"{parameter.name} (Trigger)");
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Trigger);
break;
}
}
}
if (_onEnterList == null)
{
_onEnterList = new ReorderableList(_animatorDriver.EnterTasks, typeof(AnimatorDriverTask),
true, true, true, true);
_onEnterList.drawHeaderCallback = OnDrawHeaderTaskEnter;
_onEnterList.drawElementCallback = OnDrawElementTaskEnter;
_onEnterList.elementHeightCallback = OnHeightElementTaskEnter;
}
_onEnterList.DoLayoutList();
if (_onExitList == null)
{
_onExitList = new ReorderableList(_animatorDriver.ExitTasks, typeof(AnimatorDriverTask),
true, true, true, true);
_onExitList.drawHeaderCallback = OnDrawHeaderTaskExit;
_onExitList.drawElementCallback = OnDrawElementTaskExit;
_onExitList.elementHeightCallback = OnHeightElementTaskExit;
}
_onExitList.DoLayoutList();
}
private void OnDrawHeaderTaskEnter(Rect rect)
{
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
GUI.Label(_rect, "On Enter State");
}
private void OnDrawElementTaskEnter(Rect rect, int index, bool isactive, bool isfocused)
{
if (index > _animatorDriver.EnterTasks.Count) return;
AnimatorDriverTask element = _animatorDriver.EnterTasks[index];
RenderTask(rect, element);
}
private float OnHeightElementTaskEnter(int index)
{
int length = 3;
if (index > _animatorDriver.EnterTasks.Count) return 1.25f * length * EditorGUIUtility.singleLineHeight;
AnimatorDriverTask task = _animatorDriver.EnterTasks[index];
return (length + TaskHeight(task)) * 1.25f * EditorGUIUtility.singleLineHeight;
}
private void OnDrawHeaderTaskExit(Rect rect)
{
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
GUI.Label(_rect, "On Exit State");
}
private void OnDrawElementTaskExit(Rect rect, int index, bool isactive, bool isfocused)
{
if (index > _animatorDriver.ExitTasks.Count) return;
AnimatorDriverTask element = _animatorDriver.ExitTasks[index];
RenderTask(rect, element);
}
private float OnHeightElementTaskExit(int index)
{
int length = 3;
if (index > _animatorDriver.ExitTasks.Count) return 1.25f * length * EditorGUIUtility.singleLineHeight;
AnimatorDriverTask task = _animatorDriver.ExitTasks[index];
return (length + TaskHeight(task)) * 1.25f * EditorGUIUtility.singleLineHeight;
}
private int TaskHeight(AnimatorDriverTask task)
{
int length = 0;
switch (task.aType)
{
case AnimatorDriverTask.SourceType.Static:
case AnimatorDriverTask.SourceType.Parameter:
length += 1;
break;
case AnimatorDriverTask.SourceType.Random:
length += 2;
break;
}
if (task.op != AnimatorDriverTask.Operator.Set)
{
length += 1;
switch (task.bType)
{
case AnimatorDriverTask.SourceType.Static:
case AnimatorDriverTask.SourceType.Parameter:
length += 1;
break;
case AnimatorDriverTask.SourceType.Random:
length += 2;
break;
}
}
length += 1;
return length;
}
private void RenderTask(Rect rect, AnimatorDriverTask task)
{
string formulaDisplay = "";
Rect _rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
int parameterIndex = Math.Max(animatorParamNames.FindIndex(m => m == task.targetName), 0);
EditorGUI.LabelField(_rect, "Parameter");
_rect.x += 100;
_rect.width = rect.width - 100;
int selectedIndex = EditorGUI.Popup(_rect, parameterIndex, animatorParamNamesDisplay.ToArray());
task.targetType = animatorParamTypes[selectedIndex];
task.targetName = animatorParamNames[selectedIndex];
formulaDisplay = $"{task.targetName} = ";
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(_rect, "Operation");
_rect.x += 100;
_rect.width = rect.width - 100;
task.op = (AnimatorDriverTask.Operator) EditorGUI.EnumPopup(_rect, task.op);
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(_rect, "A Type");
_rect.x += 100;
_rect.width = rect.width - 100;
task.aType = (AnimatorDriverTask.SourceType) EditorGUI.EnumPopup(_rect, task.aType);
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
switch (task.aType)
{
case AnimatorDriverTask.SourceType.Static:
EditorGUI.LabelField(_rect, "A Value");
_rect.x += 100;
_rect.width = rect.width - 100;
task.aValue = EditorGUI.FloatField(_rect, task.aValue);
formulaDisplay += $"{task.aValue} ";
break;
case AnimatorDriverTask.SourceType.Parameter:
parameterIndex = Math.Max(animatorParamNames.FindIndex(m => m == task.aName), 0);
EditorGUI.LabelField(_rect, "Parameter A");
_rect.x += 100;
_rect.width = rect.width - 100;
selectedIndex = EditorGUI.Popup(_rect, parameterIndex, animatorParamNamesDisplay.ToArray());
task.aParamType = animatorParamTypes[selectedIndex];
task.aName = animatorParamNames[selectedIndex];
formulaDisplay += $"{task.aName} ";
break;
case AnimatorDriverTask.SourceType.Random:
EditorGUI.LabelField(_rect, "A Min");
_rect.x += 100;
_rect.width = rect.width - 100;
task.aValue = EditorGUI.FloatField(_rect, task.aValue);
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(_rect, "A Max");
_rect.x += 100;
_rect.width = rect.width - 100;
task.aMax = Convert.ToSingle(EditorGUI.TextField(_rect, task.aMax.ToString()));
formulaDisplay += $"Rand({task.aValue}, {task.aMax}) ";
break;
}
if (task.op != AnimatorDriverTask.Operator.Set)
{
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
switch (task.op)
{
case AnimatorDriverTask.Operator.Addition:
formulaDisplay += "+ ";
break;
case AnimatorDriverTask.Operator.Subtraction:
formulaDisplay += "- ";
break;
case AnimatorDriverTask.Operator.Multiplication:
formulaDisplay += "* ";
break;
case AnimatorDriverTask.Operator.Division:
formulaDisplay += "/ ";
break;
case AnimatorDriverTask.Operator.Modulo:
formulaDisplay += "% ";
break;
case AnimatorDriverTask.Operator.Power:
formulaDisplay += "pow ";
break;
case AnimatorDriverTask.Operator.Log:
formulaDisplay += "log ";
break;
case AnimatorDriverTask.Operator.Equal:
formulaDisplay += "== ";
break;
case AnimatorDriverTask.Operator.LessThen:
formulaDisplay += "< ";
break;
case AnimatorDriverTask.Operator.LessEqual:
formulaDisplay += "<= ";
break;
case AnimatorDriverTask.Operator.MoreThen:
formulaDisplay += "> ";
break;
case AnimatorDriverTask.Operator.MoreEqual:
formulaDisplay += ">= ";
break;
case AnimatorDriverTask.Operator.NotEqual:
formulaDisplay += "!= ";
break;
}
EditorGUI.LabelField(_rect, "B Type");
_rect.x += 100;
_rect.width = rect.width - 100;
task.bType = (AnimatorDriverTask.SourceType) EditorGUI.EnumPopup(_rect, task.bType);
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
switch (task.bType)
{
case AnimatorDriverTask.SourceType.Static:
EditorGUI.LabelField(_rect, "B Value");
_rect.x += 100;
_rect.width = rect.width - 100;
task.bValue = EditorGUI.FloatField(_rect, task.bValue);
formulaDisplay += $"{task.bValue} ";
break;
case AnimatorDriverTask.SourceType.Parameter:
parameterIndex = Math.Max(animatorParamNames.FindIndex(m => m == task.bName), 0);
EditorGUI.LabelField(_rect, "Parameter B");
_rect.x += 100;
_rect.width = rect.width - 100;
selectedIndex = EditorGUI.Popup(_rect, parameterIndex, animatorParamNamesDisplay.ToArray());
task.bParamType = animatorParamTypes[selectedIndex];
task.bName = animatorParamNames[selectedIndex];
formulaDisplay += $"{task.bName} ";
break;
case AnimatorDriverTask.SourceType.Random:
EditorGUI.LabelField(_rect, "B Min");
_rect.x += 100;
_rect.width = rect.width - 100;
task.bValue = EditorGUI.FloatField(_rect, task.bValue);
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(_rect, "B Max");
_rect.x += 100;
_rect.width = rect.width - 100;
task.bMax = Convert.ToSingle(EditorGUI.TextField(_rect, task.bMax.ToString()));
formulaDisplay += $"Rand({task.bValue}, {task.bMax}) ";
break;
}
}
var boldtext = new GUIStyle (GUI.skin.label);
boldtext.fontStyle = FontStyle.Bold;
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(_rect, task.targetName == "- None -"?"Parameter = A":formulaDisplay, boldtext);
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cf1a3cb4c93d41c9b01fcf9f128fbca2
timeCreated: 1685439016

View file

@ -23,9 +23,9 @@ namespace ABI.CCK.Scripts.Editor
[InitializeOnLoad]
public class CCK_BuildManagerWindow : EditorWindow
{
public static string Version = "3.4 RELEASE";
public static int BuildID = 90;
private const string CCKVersion = "3.4 RELEASE (Build 92)";
public static string Version = "3.5 RELEASE";
public static int BuildID = 98;
private const string CCKVersion = "3.5 RELEASE (Build 98)";
private string[] SupportedUnityVersions = new[]
{
@ -34,7 +34,11 @@ namespace ABI.CCK.Scripts.Editor
"2019.4.13f1", "2019.4.14f1", "2019.4.15f1", "2019.4.16f1", "2019.4.17f1", "2019.4.18f1",
"2019.4.19f1", "2019.4.20f1", "2019.4.21f1", "2019.4.22f1", "2019.4.23f1", "2019.4.24f1",
"2019.4.25f1", "2019.4.26f1", "2019.4.27f1", "2019.4.28f1", "2019.4.29f1", "2019.4.30f1",
"2019.4.31f1"
"2019.4.31f1",
"2021.3.1f1", "2021.3.2f1", "2021.3.3f1", "2021.3.4f1", "2021.3.5f1", "2021.3.6f1", "2021.3.7f1",
"2021.3.8f1", "2021.3.9f1", "2021.3.10f1", "2021.3.11f1", "2021.3.12f1", "2021.3.13f1", "2021.3.14f1",
"2021.3.15f1", "2021.3.16f1", "2021.3.17f1", "2021.3.18f1", "2021.3.19f1", "2021.3.20f1", "2021.3.21f1",
"2021.3.22f1", "2021.3.23f1", "2021.3.24f1"
};
string _username;
@ -108,13 +112,41 @@ namespace ABI.CCK.Scripts.Editor
{
EditorPrefs.SetBool("m_ABI_isBuilding", false);
EditorPrefs.SetString("m_ABI_TempVersion", Version);
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRAvatar.prefab")) File.Delete(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRAvatar.prefab");
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab")) File.Delete(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab");
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab")) File.Delete(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab");
if (File.Exists(Application.persistentDataPath + "/bundle.cvravatar")) File.Delete(Application.persistentDataPath + "/bundle.cvravatar");
string[] filePaths = Directory.GetFiles(Application.dataPath + "/ABI.CCK/Resources/Cache/", "*.prefab");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
filePaths = Directory.GetFiles(Application.persistentDataPath + "/", "*.cvravatar");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
filePaths = Directory.GetFiles(Application.persistentDataPath + "/", "*.cvravatar.manifest");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
filePaths = Directory.GetFiles(Application.persistentDataPath + "/", "*.cvrprop");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
filePaths = Directory.GetFiles(Application.persistentDataPath + "/", "*.cvrprop.manifest");
foreach (string filePath in filePaths)
{
File.Delete(filePath);
}
/*if (File.Exists(Application.persistentDataPath + "/bundle.cvravatar")) File.Delete(Application.persistentDataPath + "/bundle.cvravatar");
if (File.Exists(Application.persistentDataPath + "/bundle.cvravatar.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvravatar.manifest");
if (File.Exists(Application.persistentDataPath + "/bundle.cvrprop")) File.Delete(Application.persistentDataPath + "/bundle.cvrprop");
if (File.Exists(Application.persistentDataPath + "/bundle.cvrprop.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvrprop.manifest");
if (File.Exists(Application.persistentDataPath + "/bundle.cvrprop.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvrprop.manifest");*/
if (File.Exists(Application.persistentDataPath + "/bundle.cvrworld")) File.Delete(Application.persistentDataPath + "/bundle.cvrworld");
if (File.Exists(Application.persistentDataPath + "/bundle.cvrworld.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvrworld.manifest");
if (File.Exists(Application.persistentDataPath + "/bundle.png")) File.Delete(Application.persistentDataPath + "/bundle.png");
@ -128,10 +160,15 @@ namespace ABI.CCK.Scripts.Editor
if (state == PlayModeStateChange.EnteredPlayMode && EditorPrefs.GetBool("m_ABI_isBuilding"))
{
CCK_BuildUtility.upload_id = EditorPrefs.GetString("m_ABI_uploadId");
string randomNum = EditorPrefs.GetString("m_ABI_uploadRand");
var ui = Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>("Assets/ABI.CCK/GUIAssets/CCK_UploaderHead.prefab"));
OnGuiUpdater up = ui.GetComponentInChildren<OnGuiUpdater>();
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRAvatar.prefab"))up.asset = Resources.Load<GameObject>("Cache/_CVRAvatar").GetComponent<CVRAssetInfo>();
if (File.Exists(Application.dataPath + $"/ABI.CCK/Resources/Cache/CVRAvatar_{CCK_BuildUtility.upload_id}_{randomNum}.prefab"))up.asset = Resources.Load<GameObject>($"Cache/CVRAvatar_{CCK_BuildUtility.upload_id}_{randomNum}").GetComponent<CVRAssetInfo>();
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab"))up.asset = Resources.Load<GameObject>("Cache/_CVRSpawnable").GetComponent<CVRAssetInfo>();
if (File.Exists(Application.dataPath + $"/ABI.CCK/Resources/Cache/CVRSpawnable_{CCK_BuildUtility.upload_id}_{randomNum}.prefab"))up.asset = Resources.Load<GameObject>($"Cache/CVRSpawnable_{CCK_BuildUtility.upload_id}_{randomNum}").GetComponent<CVRAssetInfo>();
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab"))up.asset = Resources.Load<GameObject>("Cache/_CVRWorld").GetComponent<CVRAssetInfo>();
}
}
@ -690,71 +727,30 @@ namespace ABI.CCK.Scripts.Editor
{
_attemptingToLogin = true;
using (HttpClient httpclient = new HttpClient())
{
HttpResponseMessage response;
response = await httpclient.PostAsync(
"https://api.abinteractive.net/1/cck/validateKey",
new StringContent(JsonConvert.SerializeObject(new {Username = _username, AccessKey = _key}),
Encoding.UTF8, "application/json")
);
APIConnection.Initialize(_username, _key);
APIConnection.BaseResponse<APIConnection.UserinfoResponse> response = await APIConnection.MakeRequest<APIConnection.UserinfoResponse>("cck/userinfo");
if (response.IsSuccessStatusCode)
if (response != null)
{
if (response.Data != null)
{
string result = await response.Content.ReadAsStringAsync();
BaseResponse<LoginResponse> usr = Abi.Newtonsoft.Json.JsonConvert.DeserializeObject<BaseResponse<LoginResponse>>(result);
if (usr == null || usr.Data == null) return;
if (usr.Data.isValidCredentials)
{
_apiUserRank = usr.Data.userRank;
Debug.Log("[ABI:CCK] Successfully authenticated as " + _username + " using AlphaLink Public API.");
EditorPrefs.SetString("m_ABI_Username", _username);
EditorPrefs.SetString("m_ABI_Key", _key);
_loggedIn = true;
_hasAttemptedToLogin = false;
}
else
{
Debug.Log("[ABI:CCK] Unable to authenticate using provided credentials. API responded with: " + usr.Message + ".");
_loggedIn = false;
_hasAttemptedToLogin = true;
_username = _key = string.Empty;
}
_apiUserRank = response.Data.UserRank;
Debug.Log("[ABI:CCK] Successfully authenticated as " + _username + " using AlphaLink Public API.");
EditorPrefs.SetString("m_ABI_Username", _username);
EditorPrefs.SetString("m_ABI_Key", _key);
_loggedIn = true;
_hasAttemptedToLogin = false;
}
else
{
Debug.LogError("[ABI:CCK] Web Request Error while trying to authenticate.");
Debug.Log("[ABI:CCK] Unable to authenticate using provided credentials. API responded with: " + response.Message + ".");
_loggedIn = false;
_hasAttemptedToLogin = true;
_username = _key = string.Empty;
}
}
_attemptingToLogin = false;
}
}
}
public class LoginResponse
{
public bool isValidCredentials { get; set; }
public bool isAccountUnlocked { get; set; }
public string userId { get; set; }
public string userRank { get; set; }
}
public class BaseResponse<T>
{
public string Message { get; set; }
public T Data { get; set; }
public BaseResponse(string message = null, T data = default)
{
Message = message;
Data = data;
}
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

View file

@ -1,11 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using ABI.CCK.Components;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using Random = System.Random;
namespace ABI.CCK.Scripts.Editor
{
@ -13,8 +16,10 @@ namespace ABI.CCK.Scripts.Editor
{
public static PreAvatarBundleEvent PreAvatarBundleEvent = new PreAvatarBundleEvent();
public static PrePropBundleEvent PrePropBundleEvent = new PrePropBundleEvent();
public static string upload_id = "";
public static void BuildAndUploadAvatar(GameObject avatarObject)
public static async Task BuildAndUploadAvatar(GameObject avatarObject)
{
//GameObject avatarCopy = null;
var origInfo = avatarObject.GetComponent<CVRAssetInfo>();
@ -33,17 +38,35 @@ namespace ABI.CCK.Scripts.Editor
//CVRAssetInfo info = avatarCopy.GetComponent<CVRAssetInfo>();
if (string.IsNullOrEmpty(origInfo.objectId))
{
origInfo.objectId = Guid.NewGuid().ToString();
//origInfo.guid = info.guid;
try
#if UNITY_EDITOR
APIConnection.Initialize(EditorPrefs.GetString("m_ABI_Username"), EditorPrefs.GetString("m_ABI_Key"));
#endif
APIConnection.BaseResponse<APIConnection.GenerateResponse> response = await APIConnection.MakeRequest<APIConnection.GenerateResponse>("cck/generate/avatar", put: true);
if (response != null && response.Data != null)
{
PrefabUtility.ApplyPrefabInstance(avatarObject, InteractionMode.UserAction);
origInfo.objectId = response.Data.Id.ToString();
}
catch
else
{
Debug.Log("[CCK:BuildUtility] Object is not a prefab. No need to Apply To Instance.");
Debug.LogError($"[CCK:BuildUtility] New Guid could not be generated");
}
}
Random rnd = new Random();
origInfo.randomNum = rnd.Next(11111111, 99999999).ToString();
EditorUtility.SetDirty(origInfo);
try
{
PrefabUtility.ApplyPrefabInstance(avatarObject, InteractionMode.UserAction);
}
catch
{
Debug.Log("[CCK:BuildUtility] Object is not a prefab. No need to Apply To Instance.");
}
PreAvatarBundleEvent.Invoke(avatarObject);
@ -51,7 +74,10 @@ namespace ABI.CCK.Scripts.Editor
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
PrefabUtility.SaveAsPrefabAsset(avatarObject, "Assets/ABI.CCK/Resources/Cache/_CVRAvatar.prefab");
if (!Application.unityVersion.Contains("2021"))
PrefabUtility.SaveAsPrefabAsset(avatarObject, "Assets/ABI.CCK/Resources/Cache/_CVRAvatar.prefab");
else
PrefabUtility.SaveAsPrefabAsset(avatarObject, $"Assets/ABI.CCK/Resources/Cache/CVRAvatar_{origInfo.objectId}_{origInfo.randomNum}.prefab");
//GameObject.DestroyImmediate(avatarCopy);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
@ -59,11 +85,19 @@ namespace ABI.CCK.Scripts.Editor
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
AssetBundleBuild assetBundleBuild = new AssetBundleBuild();
assetBundleBuild.assetNames = new[] {"Assets/ABI.CCK/Resources/Cache/_CVRAvatar.prefab"};
assetBundleBuild.assetBundleName = "bundle.cvravatar";
if (!Application.unityVersion.Contains("2021"))
assetBundleBuild.assetNames = new[] {"Assets/ABI.CCK/Resources/Cache/_CVRAvatar.prefab"};
else
assetBundleBuild.assetNames = new[] {$"Assets/ABI.CCK/Resources/Cache/CVRAvatar_{origInfo.objectId}_{origInfo.randomNum}.prefab"};
upload_id = origInfo.objectId;
EditorPrefs.SetString("m_ABI_uploadId", upload_id);
EditorPrefs.SetString("m_ABI_uploadRand", origInfo.randomNum);
assetBundleBuild.assetBundleName = $"cvravatar_{origInfo.objectId}_{origInfo.randomNum}.cvravatar";
BuildPipeline.BuildAssetBundles(Application.persistentDataPath, new[] {assetBundleBuild},
BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh();
@ -71,13 +105,35 @@ namespace ABI.CCK.Scripts.Editor
EditorApplication.isPlaying = true;
}
public static void BuildAndUploadSpawnable(GameObject s)
public static async Task BuildAndUploadSpawnable(GameObject s)
{
GameObject sCopy = null;
var origInfo = s.GetComponent<CVRAssetInfo>();
var spawnable = s.GetComponent<CVRSpawnable>();
spawnable.spawnableType = CVRSpawnable.SpawnableType.StandaloneSpawnable;
if (string.IsNullOrEmpty(origInfo.objectId))
{
#if UNITY_EDITOR
APIConnection.Initialize(EditorPrefs.GetString("m_ABI_Username"), EditorPrefs.GetString("m_ABI_Key"));
#endif
APIConnection.BaseResponse<APIConnection.GenerateResponse> response = await APIConnection.MakeRequest<APIConnection.GenerateResponse>("cck/generate/spawnable", put: true);
if (response != null && response.Data != null)
{
origInfo.objectId = response.Data.Id.ToString();
}
else
{
Debug.LogError($"[CCK:BuildUtility] New Guid could not be generated");
}
}
Random rnd = new Random();
origInfo.randomNum = rnd.Next(11111111, 99999999).ToString();
EditorUtility.SetDirty(origInfo);
PrePropBundleEvent.Invoke(s);
try
@ -92,25 +148,25 @@ namespace ABI.CCK.Scripts.Editor
}
CVRAssetInfo info = sCopy.GetComponent<CVRAssetInfo>();
if (string.IsNullOrEmpty(info.objectId))
try
{
info.objectId = Guid.NewGuid().ToString();
origInfo.objectId = info.objectId;
try
{
PrefabUtility.ApplyPrefabInstance(s, InteractionMode.UserAction);
}
catch
{
Debug.Log("[CCK:BuildUtility] Object is not a prefab. No need to Apply To Instance.");
}
PrefabUtility.ApplyPrefabInstance(s, InteractionMode.UserAction);
}
catch
{
Debug.Log("[CCK:BuildUtility] Object is not a prefab. No need to Apply To Instance.");
}
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
PrefabUtility.SaveAsPrefabAsset(sCopy, "Assets/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab");
if (!Application.unityVersion.Contains("2021"))
PrefabUtility.SaveAsPrefabAsset(sCopy, "Assets/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab");
else
PrefabUtility.SaveAsPrefabAsset(sCopy, $"Assets/ABI.CCK/Resources/Cache/CVRSpawnable_{origInfo.objectId}_{origInfo.randomNum}.prefab");
GameObject.DestroyImmediate(sCopy);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
@ -118,11 +174,20 @@ namespace ABI.CCK.Scripts.Editor
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
AssetBundleBuild assetBundleBuild = new AssetBundleBuild();
assetBundleBuild.assetNames = new[] {"Assets/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab"};
assetBundleBuild.assetBundleName = "bundle.cvrprop";
if (!Application.unityVersion.Contains("2021"))
assetBundleBuild.assetNames = new[] {"Assets/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab"};
else
assetBundleBuild.assetNames = new[] {$"Assets/ABI.CCK/Resources/Cache/CVRSpawnable_{origInfo.objectId}_{origInfo.randomNum}.prefab"};
upload_id = origInfo.objectId;
EditorPrefs.SetString("m_ABI_uploadId", upload_id);
EditorPrefs.SetString("m_ABI_uploadRand", origInfo.randomNum);
assetBundleBuild.assetBundleName = $"cvrspawnable_{origInfo.objectId}_{origInfo.randomNum}.cvrprop";
BuildPipeline.BuildAssetBundles(Application.persistentDataPath, new[] {assetBundleBuild},
BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh();
@ -130,17 +195,35 @@ namespace ABI.CCK.Scripts.Editor
EditorApplication.isPlaying = true;
}
public static void BuildAndUploadMapAsset(Scene scene, GameObject descriptor)
public static async Task BuildAndUploadMapAsset(Scene scene, GameObject descriptor)
{
SetupNetworkUUIDs();
CVRAssetInfo info = descriptor.GetComponent<CVRAssetInfo>();
if (string.IsNullOrEmpty(info.objectId))
{
#if UNITY_EDITOR
APIConnection.Initialize(EditorPrefs.GetString("m_ABI_Username"), EditorPrefs.GetString("m_ABI_Key"));
#endif
APIConnection.BaseResponse<APIConnection.GenerateResponse> response = await APIConnection.MakeRequest<APIConnection.GenerateResponse>("cck/generate/world", put: true);
if (response != null && response.Data != null)
{
info.objectId = response.Data.Id.ToString();
EditorUtility.SetDirty(info);
}
else
{
Debug.LogError($"[CCK:BuildUtility] New Guid could not be generated");
}
}
EditorSceneManager.MarkSceneDirty(scene);
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
CVRAssetInfo info = descriptor.GetComponent<CVRAssetInfo>();
if (string.IsNullOrEmpty(info.objectId)) info.objectId = Guid.NewGuid().ToString();
PrefabUtility.SaveAsPrefabAsset(descriptor, "Assets/ABI.CCK/Resources/Cache/_CVRWorld.prefab");
AssetBundleBuild assetBundleBuild = new AssetBundleBuild();
@ -148,7 +231,7 @@ namespace ABI.CCK.Scripts.Editor
assetBundleBuild.assetBundleName = "bundle.cvrworld";
BuildPipeline.BuildAssetBundles(Application.persistentDataPath, new[] {assetBundleBuild},
BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh();

View file

@ -109,18 +109,33 @@ namespace ABI.CCK.Scripts.Editor
if (_driver.animators[index] != null && _driver.animators[index].runtimeAnimatorController != null)
{
var controller = (AnimatorController) _driver.animators[index].runtimeAnimatorController;
foreach (var parameter in controller.parameters)
var runtimeController = _driver.animators[index].runtimeAnimatorController;
UnityEngine.AnimatorControllerParameter[] parameters = null;
if (runtimeController is AnimatorController animatorController)
{
animatorParamNameList.Add(parameter.name);
animatorParamTypeList.Add(parameter.type);
parameters = animatorController.parameters;
}
else if (runtimeController is AnimatorOverrideController overrideController &&
overrideController.runtimeAnimatorController is AnimatorController baseController)
{
parameters = baseController.parameters;
}
if (_driver.animatorParameters[index] == parameter.name)
if (parameters != null)
{
foreach (var parameter in parameters)
{
oldIndex = i;
}
animatorParamNameList.Add(parameter.name);
animatorParamTypeList.Add(parameter.type);
i++;
if (_driver.animatorParameters[index] == parameter.name)
{
oldIndex = i;
}
i++;
}
}
}

View file

@ -105,6 +105,9 @@ namespace ABI.CCK.Scripts.Editor
_avatar.visemeMode = (CVRAvatar.CVRAvatarVisemeMode) EditorGUILayout.EnumPopup("Lip Sync Mode", _avatar.visemeMode);
if (_avatar.visemeMode == CVRAvatar.CVRAvatarVisemeMode.Visemes)
_avatar.visemeSmoothing = EditorGUILayout.IntSlider("Viseme Smoothing", _avatar.visemeSmoothing, 0, 100);
if (_avatar.visemeBlendshapes == null || _avatar.visemeBlendshapes.Length != _visemeNames.Length)
_avatar.visemeBlendshapes = new string[_visemeNames.Length];
@ -153,7 +156,7 @@ namespace ABI.CCK.Scripts.Editor
if (_avatar.enableAdvancedTagging)
{
EditorGUILayout.HelpBox("Attention! If you are using the Advanced Tagging System, you still need to Tag your Avatar appropriately and Set all affected GameObjects here.", MessageType.Warning);
EditorGUILayout.HelpBox("If you are using the Advanced Tagging System, you do not need to Tag your Avatar appropriately if you mark all affected GameObjects here.", MessageType.Info);
if (taggingList == null) InitializeTaggingList();
taggingList.DoLayoutList();
@ -429,7 +432,7 @@ namespace ABI.CCK.Scripts.Editor
float height = 10.50f;
if (gameObjectToggle.useAnimationClip)
{
height -= 1.25f;
//height -= 1.25f;
}
else
{
@ -781,6 +784,15 @@ namespace ABI.CCK.Scripts.Editor
_rect.x += 100;
_rect.width = rect.width - 100;
gameObjectToggle.animationClip = (AnimationClip)EditorGUI.ObjectField(_rect, gameObjectToggle.animationClip, typeof(AnimationClip), true);
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
// Animation Clip Slot
EditorGUI.LabelField(_rect, "Off Clip");
_rect.x += 100;
_rect.width = rect.width - 100;
gameObjectToggle.offAnimationClip = (AnimationClip)EditorGUI.ObjectField(_rect, gameObjectToggle.offAnimationClip, typeof(AnimationClip), true);
}
else
{

View file

@ -455,6 +455,12 @@ namespace ABI.CCK.Scripts.Editor
break;
case CVRInteractableActionOperation.ActionType.DisplaySpawnableDetailPage:
trigger.operations[j].stringVal = EditorGUILayout.TextField("Spawnable GUID:", trigger.operations[j].stringVal);
break;
case CVRInteractableActionOperation.ActionType.SitAtPosition:
trigger.operations[j].gameObjectVal = (GameObject)EditorGUILayout.ObjectField(

View file

@ -133,7 +133,7 @@ public class CCK_CVR_VideoPlayerEditor : Editor
{
#region General settings
_showGeneral = EditorGUILayout.BeginFoldoutHeaderGroup(_showGeneral, "General");
_showGeneral = EditorGUILayout.Foldout(_showGeneral, "General");
if (_showGeneral)
{
_player.syncEnabled = EditorGUILayout.Toggle("Network Sync", _player.syncEnabled);
@ -170,14 +170,11 @@ public class CCK_CVR_VideoPlayerEditor : Editor
EditorGUILayout.Space();
}
EditorGUILayout.EndFoldoutHeaderGroup();
#endregion
#region Audio settings
_showAudio = EditorGUILayout.BeginFoldoutHeaderGroup(_showAudio, "Audio");
_showAudio = EditorGUILayout.Foldout(_showAudio, "Audio");
if (_showAudio)
{
_player.playbackVolume = EditorGUILayout.Slider("Playback Volume", _player.playbackVolume, 0.0f, 1.0f);
@ -190,15 +187,12 @@ public class CCK_CVR_VideoPlayerEditor : Editor
EditorGUILayout.Space();
}
EditorGUILayout.EndFoldoutHeaderGroup();
#endregion
#region Playlists
_showPlaylists = EditorGUILayout.BeginFoldoutHeaderGroup(_showPlaylists, "Playlists");
_showPlaylists = EditorGUILayout.Foldout(_showPlaylists, "Playlists");
if (_showPlaylists)
{
EditorGUILayout.LabelField(new GUIContent("Play On Awake Object", "Default video to play on start/awake"), new GUIContent(_player.playOnAwakeObject?.videoTitle));
@ -211,14 +205,11 @@ public class CCK_CVR_VideoPlayerEditor : Editor
EditorGUILayout.Space();
}
EditorGUILayout.EndFoldoutHeaderGroup();
#endregion
#region Events
_showEvents = EditorGUILayout.BeginFoldoutHeaderGroup(_showEvents, "Events");
if (_showEvents)
{
serializedObject.Update();
@ -238,8 +229,6 @@ public class CCK_CVR_VideoPlayerEditor : Editor
serializedObject.ApplyModifiedProperties();
EditorGUILayout.Space();
}
EditorGUILayout.EndFoldoutHeaderGroup();
#endregion
}

View file

@ -1,7 +1,9 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.XR;
#pragma warning disable
@ -13,13 +15,25 @@ public class CCK_Init
void SetTag(SerializedProperty tags, string name, int index)
{
SerializedProperty sp = tags.GetArrayElementAtIndex(index);
SerializedProperty sp = null;
try
{
sp = tags.GetArrayElementAtIndex(index);
}
catch{}
if (sp != null) sp.stringValue = name;
}
void SetLayer(SerializedProperty layers, string name, int index)
{
SerializedProperty sp = layers.GetArrayElementAtIndex(index);
SerializedProperty sp = null;
try
{
sp = layers.GetArrayElementAtIndex(index);
}
catch{}
if (sp != null) sp.stringValue = name;
}
@ -73,17 +87,33 @@ public class CCK_Init
tagManager.ApplyModifiedProperties();
}
#if UNITY_2021_1_OR_NEWER
if (true)
#else
if (!PlayerSettings.virtualRealitySupported)
#endif
{
Debug.Log("[CCK:Init] XR and render settings have to be changed. Now changing.");
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
#if PLATFORM_ANDROID
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.Android);
#else
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows64)
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
#endif
PlayerSettings.colorSpace = UnityEngine.ColorSpace.Linear;
PlayerSettings.apiCompatibilityLevel = ApiCompatibilityLevel.NET_4_6;
#if UNITY_2021_1_OR_NEWER
PlayerSettings.virtualRealitySupported = true;
PlayerSettings.stereoRenderingPath = StereoRenderingPath.Instancing;
XRSettings.enabled = false;
#else
PlayerSettings.virtualRealitySupported = true;
PlayerSettings.SetVirtualRealitySDKs(BuildTargetGroup.Standalone, new string[] { "None", "Oculus", "OpenVR", "MockHMD" });
PlayerSettings.stereoRenderingPath = StereoRenderingPath.SinglePass;
#endif
}
if (LayerMask.LayerToName(10) == "PlayerNetwork" && LayerMask.LayerToName(17) == "CVRPickup" && LayerMask.LayerToName(15) == "CVRReserved4" && PlayerSettings.virtualRealitySupported )