diff --git a/Assets/ABI.CCK/Components/AnimatorDriver.cs b/Assets/ABI.CCK/Components/AnimatorDriver.cs new file mode 100755 index 0000000..6e8435a --- /dev/null +++ b/Assets/ABI.CCK/Components/AnimatorDriver.cs @@ -0,0 +1,209 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace ABI.CCK.Components +{ + public class AnimatorDriver : StateMachineBehaviour + { + public List EnterTasks = new List(); + public List ExitTasks = new List(); + + public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) + { + foreach (var task in EnterTasks) + { + task.Execute(animator); + } + } + + public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) + { + foreach (var task in ExitTasks) + { + task.Execute(animator); + } + } + } + + [System.Serializable] + public class AnimatorDriverTask + { + public enum Operator + { + Set, + Addition, + Subtraction, + Multiplication, + Division, + Modulo, + Power, + Log, + Equal, + NotEqual, + LessThen, + LessEqual, + MoreThen, + MoreEqual + } + + public enum SourceType + { + Static, + Parameter, + Random + } + + public enum ParameterType + { + None, + Float, + Int, + Bool, + Trigger + } + + public ParameterType targetType = ParameterType.None; + public string targetName = ""; + + public Operator op = Operator.Set; + + public SourceType aType = SourceType.Static; + public float aValue = 0f; + public float aMax = 1f; + public ParameterType aParamType; + public string aName = ""; + + public SourceType bType = SourceType.Static; + public float bValue = 0f; + public float bMax = 1f; + public ParameterType bParamType; + public string bName = ""; + + public void Execute(Animator animator) + { + float valA = 0f; + float valB = 0f; + float res = 0f; + + switch (aType) + { + case SourceType.Static: + valA = aValue; + break; + case SourceType.Random: + valA = Random.Range(aValue, aMax); + break; + case SourceType.Parameter: + switch (aParamType) + { + default: + valA = 0f; + break; + case ParameterType.Bool: + valA = animator.GetBool(aName) ? 1f : 0f; + break; + case ParameterType.Float: + valA = animator.GetFloat(aName); + break; + case ParameterType.Int: + valA = animator.GetInteger(aName); + break; + } + break; + } + + if (op == Operator.Set) + { + res = valA; + } + else + { + switch (bType) + { + case SourceType.Static: + valB = bValue; + break; + case SourceType.Random: + valB = Random.Range(bValue, aMax); + break; + case SourceType.Parameter: + switch (aParamType) + { + default: + valB = 0f; + break; + case ParameterType.Bool: + valB = animator.GetBool(bName) ? 1f : 0f; + break; + case ParameterType.Float: + valB = animator.GetFloat(bName); + break; + case ParameterType.Int: + valB = animator.GetInteger(bName); + break; + } + break; + } + + switch (op) + { + case Operator.Addition: + res = valA + valB; + break; + case Operator.Subtraction: + res = valA - valB; + break; + case Operator.Multiplication: + res = valA * valB; + break; + case Operator.Division: + res = valA / valB; + break; + case Operator.Modulo: + res = valA % valB; + break; + case Operator.Power: + res = Mathf.Pow(valA, valB); + break; + case Operator.Log: + res = Mathf.Log(valA, valB); + break; + case Operator.Equal: + res = valA == valB ? 1f : 0f; + break; + case Operator.NotEqual: + res = valA != valB ? 1f : 0f; + break; + case Operator.LessThen: + res = valA < valB ? 1f : 0f; + break; + case Operator.LessEqual: + res = valA <= valB ? 1f : 0f; + break; + case Operator.MoreThen: + res = valA > valB ? 1f : 0f; + break; + case Operator.MoreEqual: + res = valA >= valB ? 1f : 0f; + break; + } + } + + switch (targetType) + { + case ParameterType.Bool: + animator.SetBool(targetName, res >= 0.5f); + break; + case ParameterType.Trigger: + if (res >= 0.5f) animator.SetTrigger(targetName); + break; + case ParameterType.Float: + animator.SetFloat(targetName, res); + break; + case ParameterType.Int: + animator.SetInteger(targetName, (int) res); + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/ABI.CCK/Components/AnimatorDriver.cs.meta b/Assets/ABI.CCK/Components/AnimatorDriver.cs.meta new file mode 100755 index 0000000..dd3c423 --- /dev/null +++ b/Assets/ABI.CCK/Components/AnimatorDriver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6007a7c7844c4bcc994fd9111bf4d5a5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ABI.CCK/Components/CVRAssetInfo.cs b/Assets/ABI.CCK/Components/CVRAssetInfo.cs index 60b4282..2ca2be4 100755 --- a/Assets/ABI.CCK/Components/CVRAssetInfo.cs +++ b/Assets/ABI.CCK/Components/CVRAssetInfo.cs @@ -17,5 +17,8 @@ namespace ABI.CCK.Components public AssetType type; public string objectId; + + [HideInInspector] + public string randomNum; } } diff --git a/Assets/ABI.CCK/Components/CVRAttachment.cs b/Assets/ABI.CCK/Components/CVRAttachment.cs index b1d3b2d..f987128 100755 --- a/Assets/ABI.CCK/Components/CVRAttachment.cs +++ b/Assets/ABI.CCK/Components/CVRAttachment.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System.Collections.Generic; +using UnityEngine; using UnityEngine.Events; namespace ABI.CCK.Components @@ -10,6 +11,7 @@ namespace ABI.CCK.Components { Bone = 1, Tracker = 2, + SnappingPoint = 4, } public AttachmentType attachmentType; @@ -52,6 +54,8 @@ namespace ABI.CCK.Components } public TrackerType trackerType = 0; + + public List snappingPointTypes = new List(); public bool useFixedPositionOffset = false; public bool useFixedRotationOffset = false; diff --git a/Assets/ABI.CCK/Components/CVRAvatar.cs b/Assets/ABI.CCK/Components/CVRAvatar.cs index 8fed611..2d52469 100755 --- a/Assets/ABI.CCK/Components/CVRAvatar.cs +++ b/Assets/ABI.CCK/Components/CVRAvatar.cs @@ -37,6 +37,8 @@ namespace ABI.CCK.Components public CVRAvatarVisemeMode visemeMode = CVRAvatarVisemeMode.Visemes; + public int visemeSmoothing = 50; + public string[] visemeBlendshapes = new string[15]; [Space] [Header("Avatar customization")] [Space] @@ -82,8 +84,8 @@ namespace ABI.CCK.Components FlashingLights = 16, Violence = 32, Gore = 64, - //Suggestive = 128, - //Nudity = 256, + Suggestive = 128, + Nudity = 256, Horror = 512 } diff --git a/Assets/ABI.CCK/Components/CVRInteractableAction.cs b/Assets/ABI.CCK/Components/CVRInteractableAction.cs index 97a4801..04a9cfc 100755 --- a/Assets/ABI.CCK/Components/CVRInteractableAction.cs +++ b/Assets/ABI.CCK/Components/CVRInteractableAction.cs @@ -123,6 +123,11 @@ namespace ABI.CCK.Components Alpha7 = KeyCode.Alpha7, Alpha8 = KeyCode.Alpha8, Alpha9 = KeyCode.Alpha9, + LeftShift = KeyCode.LeftShift, + RightShift = KeyCode.RightShift, + LeftControl = KeyCode.LeftControl, + RightControl = KeyCode.RightControl, + Space = KeyCode.Space, InputHorizontalNegative = 10000, InputHorizontalPositive = 10001, InputVerticalNegative = 10002, diff --git a/Assets/ABI.CCK/Components/CVRInteractableActionOperation.cs b/Assets/ABI.CCK/Components/CVRInteractableActionOperation.cs index 450f3d8..9034f52 100755 --- a/Assets/ABI.CCK/Components/CVRInteractableActionOperation.cs +++ b/Assets/ABI.CCK/Components/CVRInteractableActionOperation.cs @@ -29,6 +29,7 @@ namespace ABI.CCK.Components DisplayWorldDetailPage = 13, DisplayInstanceDetailPage = 14, DisplayAvatarDetailPage = 15, + DisplaySpawnableDetailPage = 37, SitAtPosition = 16, MethodCall = 21, SetSpawnableValue = 22, diff --git a/Assets/ABI.CCK/Components/CombatSystem.cs b/Assets/ABI.CCK/Components/CombatSystem.cs index 57d4cdd..3bea52e 100755 --- a/Assets/ABI.CCK/Components/CombatSystem.cs +++ b/Assets/ABI.CCK/Components/CombatSystem.cs @@ -24,12 +24,15 @@ namespace ABI.CCK.Components [Header("Events")] public UnityEvent playerDownEvent = new UnityEvent(); + public UnityEvent playerHitEvent = new UnityEvent(); public UnityEvent playerRespawnEvent = new UnityEvent(); public UnityEvent playerRevitalizeEvent = new UnityEvent(); [Header("PVP Events")] public UnityEvent playerDownedEvent = new UnityEvent(); public UnityEvent downedAnotherPlayerEvent = new UnityEvent(); + public UnityEvent playerGotHitEvent = new UnityEvent(); + public UnityEvent hitAnotherPlayerEvent = new UnityEvent(); private void Reset() { diff --git a/Assets/ABI.CCK/Components/GameInstanceController.cs b/Assets/ABI.CCK/Components/GameInstanceController.cs index 5525239..5a93e45 100755 --- a/Assets/ABI.CCK/Components/GameInstanceController.cs +++ b/Assets/ABI.CCK/Components/GameInstanceController.cs @@ -103,5 +103,7 @@ namespace ABI.CCK.Components public UnityEvent teamLeaveEvent = new UnityEvent(); public UnityEvent teamWinRoundEvent = new UnityEvent(); public UnityEvent teamWinGameEvent = new UnityEvent(); + public UnityEvent teamMemberReadyEvent = new UnityEvent(); + public UnityEvent teamMemberUnReadyEvent = new UnityEvent(); } } \ No newline at end of file diff --git a/Assets/ABI.CCK/Components/GunController.cs b/Assets/ABI.CCK/Components/GunController.cs index 72f7e54..3ce764e 100755 --- a/Assets/ABI.CCK/Components/GunController.cs +++ b/Assets/ABI.CCK/Components/GunController.cs @@ -25,6 +25,15 @@ namespace ABI.CCK.Components public FiringMode firingMode = FiringMode.HalfAuto; public float firingRate = 1f; public float reloadTime = 1f; + + public enum HitDetection + { + Particle = 0, + Raycast = 1, + } + + public HitDetection hitDetection = HitDetection.Particle; + public LayerMask hitMask = (1 << 0) | (1 << 8); public void Shoot() { diff --git a/Assets/ABI.CCK/Components/ObjectHealth.cs b/Assets/ABI.CCK/Components/ObjectHealth.cs index 8e24fd6..5887a24 100755 --- a/Assets/ABI.CCK/Components/ObjectHealth.cs +++ b/Assets/ABI.CCK/Components/ObjectHealth.cs @@ -11,11 +11,16 @@ namespace ABI.CCK.Components { Destroy = 0, RespawnAfterTime = 1, + RespawnOnRoundStart = 2, + RespawnOnRoundEnd = 3, + RespawnOnGameStart = 4, + RespawnOnGameEnd = 5, } [Header("Down Behavior")] public DownBehavior downBehavior = DownBehavior.Destroy; public float respawnTime = 10f; public Transform respawnPoint; + public GameInstanceController connectedGameInstance; [Header("Events")] public UnityEvent downEvent = new UnityEvent(); diff --git a/Assets/ABI.CCK/Components/PlayerMaterialParser.cs b/Assets/ABI.CCK/Components/PlayerMaterialParser.cs new file mode 100755 index 0000000..33642d9 --- /dev/null +++ b/Assets/ABI.CCK/Components/PlayerMaterialParser.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace ABI.CCK.Components +{ + public class PlayerMaterialParser : MonoBehaviour + { + public Material targetMaterial; + + public string playerRootPositions = "_PlayerRootPositions"; + public string playerHipPositions = "_PlayerHipPositions"; + public string playerHeadPositions = "_PlayerHeadPositions"; + public string playerLeftHandPositions = "_PlayerLeftHandPositions"; + public string playerRightHandPositions = "_PlayerRightHandPositions"; + public string playerChestPositions = "_PlayerChestPositions"; + public string playerLeftFootPositions = "_PlayerLeftFootPositions"; + public string playerRightFootPositions = "_PlayerRightFootPositions"; + } +} diff --git a/Assets/ABI.CCK/Components/PlayerMaterialParser.cs.meta b/Assets/ABI.CCK/Components/PlayerMaterialParser.cs.meta new file mode 100755 index 0000000..b538903 --- /dev/null +++ b/Assets/ABI.CCK/Components/PlayerMaterialParser.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5256473d683a24743ab8a6b352997437 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ABI.CCK/Components/SpawnablePickupMarker.cs b/Assets/ABI.CCK/Components/SpawnablePickupMarker.cs new file mode 100755 index 0000000..a5e556d --- /dev/null +++ b/Assets/ABI.CCK/Components/SpawnablePickupMarker.cs @@ -0,0 +1,27 @@ +using UnityEngine; + +namespace ABI.CCK.Components +{ + public class SpawnablePickupMarker : MonoBehaviour + { + public string spawnableGuid; + + private void OnDrawGizmos() + { + Gizmos.color = Color.magenta; + Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale); + Gizmos.matrix = rotationMatrix; + Gizmos.DrawWireCube(new Vector3(0, 0.75f, 0), new Vector3(1f, 1.5f, 0f)); + + Gizmos.DrawWireCube(new Vector3(0, 0.7f, 0), new Vector3(0.8f, 0.1f, 0f)); + Gizmos.DrawWireCube(new Vector3(0, 0.615f, 0), new Vector3(0.6f, 0.07f, 0f)); + Gizmos.DrawWireCube(new Vector3(0.24f, 0.28f, 0), new Vector3(0.32f, 0.42f, 0f)); + Gizmos.DrawWireCube(new Vector3(-0.24f, 0.28f, 0), new Vector3(0.32f, 0.42f, 0f)); + var scale = transform.lossyScale; + scale.Scale(new Vector3(1f, 1f, 0f)); + rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, scale); + Gizmos.matrix = rotationMatrix; + Gizmos.DrawWireSphere(new Vector3(0, 1.11f, 0), 0.31f); + } + } +} \ No newline at end of file diff --git a/Assets/ABI.CCK/Components/SpawnablePickupMarker.cs.meta b/Assets/ABI.CCK/Components/SpawnablePickupMarker.cs.meta new file mode 100755 index 0000000..fb72485 --- /dev/null +++ b/Assets/ABI.CCK/Components/SpawnablePickupMarker.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eff309c86b8103c45a87cf57553d787f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ABI.CCK/GUIAssets/CCK_UploaderHead.prefab b/Assets/ABI.CCK/GUIAssets/CCK_UploaderHead.prefab index 96c9168..5e4a1f2 100755 --- a/Assets/ABI.CCK/GUIAssets/CCK_UploaderHead.prefab +++ b/Assets/ABI.CCK/GUIAssets/CCK_UploaderHead.prefab @@ -17079,7 +17079,7 @@ MonoBehaviour: m_HorizontalOverflow: 1 m_VerticalOverflow: 1 m_LineSpacing: 1 - m_Text: ABI Platform Content Creation Kit v3.4 RELEASE (Build 92, Public) + m_Text: ABI Platform Content Creation Kit v3.5 RELEASE (Build 98, Public) --- !u!1 &8389522060313083026 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/ABI.CCK/Materials/UI Additive.mat b/Assets/ABI.CCK/Materials/UI Additive.mat index cf97815..4109985 100755 Binary files a/Assets/ABI.CCK/Materials/UI Additive.mat and b/Assets/ABI.CCK/Materials/UI Additive.mat differ diff --git a/Assets/ABI.CCK/Materials/VideoPlayerSpeaker.mat b/Assets/ABI.CCK/Materials/VideoPlayerSpeaker.mat index 3acccb7..cd659d9 100755 Binary files a/Assets/ABI.CCK/Materials/VideoPlayerSpeaker.mat and b/Assets/ABI.CCK/Materials/VideoPlayerSpeaker.mat differ diff --git a/Assets/ABI.CCK/Materials/VideoScreen.mat b/Assets/ABI.CCK/Materials/VideoScreen.mat index c577ec8..4624e0b 100755 Binary files a/Assets/ABI.CCK/Materials/VideoScreen.mat and b/Assets/ABI.CCK/Materials/VideoScreen.mat differ diff --git a/Assets/ABI.CCK/Prefabs/CVRVideoPlayerCinemaScreen.prefab b/Assets/ABI.CCK/Prefabs/CVRVideoPlayerCinemaScreen.prefab index 91b31f8..f45c35a 100755 Binary files a/Assets/ABI.CCK/Prefabs/CVRVideoPlayerCinemaScreen.prefab and b/Assets/ABI.CCK/Prefabs/CVRVideoPlayerCinemaScreen.prefab differ diff --git a/Assets/ABI.CCK/Prefabs/Chair.prefab b/Assets/ABI.CCK/Prefabs/Chair.prefab index ab8f7ab..338d9bd 100755 Binary files a/Assets/ABI.CCK/Prefabs/Chair.prefab and b/Assets/ABI.CCK/Prefabs/Chair.prefab differ diff --git a/Assets/ABI.CCK/Prefabs/Mirror.prefab b/Assets/ABI.CCK/Prefabs/Mirror.prefab index 6a8600f..3c50b10 100755 Binary files a/Assets/ABI.CCK/Prefabs/Mirror.prefab and b/Assets/ABI.CCK/Prefabs/Mirror.prefab differ diff --git a/Assets/ABI.CCK/Prefabs/VideoPlayer/Speakers.prefab b/Assets/ABI.CCK/Prefabs/VideoPlayer/Speakers.prefab index d1d726f..f7257f7 100755 Binary files a/Assets/ABI.CCK/Prefabs/VideoPlayer/Speakers.prefab and b/Assets/ABI.CCK/Prefabs/VideoPlayer/Speakers.prefab differ diff --git a/Assets/ABI.CCK/Prefabs/VideoPlayer/VideoPlayerRoomScaleAudioPrefab.prefab b/Assets/ABI.CCK/Prefabs/VideoPlayer/VideoPlayerRoomScaleAudioPrefab.prefab index 3f9d833..24370a2 100755 Binary files a/Assets/ABI.CCK/Prefabs/VideoPlayer/VideoPlayerRoomScaleAudioPrefab.prefab and b/Assets/ABI.CCK/Prefabs/VideoPlayer/VideoPlayerRoomScaleAudioPrefab.prefab differ diff --git a/Assets/ABI.CCK/Prefabs/VideoPlayer/VideoPlayerUiPrefab.prefab b/Assets/ABI.CCK/Prefabs/VideoPlayer/VideoPlayerUiPrefab.prefab index 1758b9c..bdc0a3b 100755 Binary files a/Assets/ABI.CCK/Prefabs/VideoPlayer/VideoPlayerUiPrefab.prefab and b/Assets/ABI.CCK/Prefabs/VideoPlayer/VideoPlayerUiPrefab.prefab differ diff --git a/Assets/ABI.CCK/Prefabs/VideoPlayer/_AudioSourceRoom.prefab b/Assets/ABI.CCK/Prefabs/VideoPlayer/_AudioSourceRoom.prefab index 38f7546..2cdfbad 100755 Binary files a/Assets/ABI.CCK/Prefabs/VideoPlayer/_AudioSourceRoom.prefab and b/Assets/ABI.CCK/Prefabs/VideoPlayer/_AudioSourceRoom.prefab differ diff --git a/Assets/ABI.CCK/Scripts/APIConnection.cs b/Assets/ABI.CCK/Scripts/APIConnection.cs new file mode 100755 index 0000000..5a5708b --- /dev/null +++ b/Assets/ABI.CCK/Scripts/APIConnection.cs @@ -0,0 +1,176 @@ +using System; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Abi.Newtonsoft.Json; +using Abi.Newtonsoft.Json.Linq; +using UnityEngine; +using Object = System.Object; + +public static class APIConnection +{ + public static string APIAddress = "https://api.abinteractive.net"; + public static string APIVersion = "2"; + private static string _apiUserAgent = "ChilloutVR API-Requests"; + + private static HttpClient _client = new HttpClient(); + + private static string _username; + private static string _accessKey; + + private static bool _initialized = false; + public static bool Initialized + { + get => _initialized; + } + + public static void Initialize(string username, string accessKey) + { + if (username == "" || accessKey == "") return; + + _username = username; + _accessKey = accessKey; + + _client.DefaultRequestHeaders.Clear(); + + _client.DefaultRequestHeaders.Add("Username", _username); + _client.DefaultRequestHeaders.Add("AccessKey", _accessKey); + _client.DefaultRequestHeaders.Add("User-Agent", _apiUserAgent); + + _client.Timeout = TimeSpan.FromSeconds(30); + _initialized = true; + } + + public static async Task> MakeRequest(string url, Object data = null, string apiVersion = null, bool put = false) + { + if (!_initialized) return default(BaseResponse); + + JObject currentRequestData; + string currentRequestUrl = String.Empty; + int currentRequestType = 0; + + if (apiVersion == null) apiVersion = APIVersion; + + currentRequestUrl = $"{APIAddress}/{apiVersion}/{url}"; + + HttpResponseMessage response; + if (data != null) currentRequestType = 1; + if (put) currentRequestType = 2; + + if (currentRequestType == 0) + { + response = await _client.GetAsync(currentRequestUrl); + } + else if (currentRequestType == 2) + { + response = await _client.PutAsync(currentRequestUrl, null); + } + else + { + response = await _client.PostAsync(currentRequestUrl, new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json")); + } + + + if (response.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject>(await response.Content.ReadAsStringAsync()); + } + else + { + Debug.LogError($"Result from API Request {currentRequestUrl} returned {response.StatusCode}"); + } + + try + { + BaseResponse res = JsonConvert.DeserializeObject>(await response.Content.ReadAsStringAsync()); + if (res != null) + return res; + } + catch (Exception e) + { + Debug.LogError($"Result from API Request {currentRequestUrl} could not be parsed"); + } + + return default(BaseResponse); + } + + //Responses + public class BaseResponse + { + 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); + } + } + + public class UserinfoResponse + { + public bool IsAccountUnlocked { get; set; } + public string UserId { get; set; } + public string Name { get; set; } + public string UserRank { get; set; } + } + + public enum ContentTypes + { + Avatar, + World, + Spawnable + } + + public class GenerateResponse + { + public Guid Id { get; set; } + public ContentTypes Type { get; set; } + } + + public class ContentInfoResponse + { + public string UploadLocation { get; set; } + public ContentDataIni ContentData { get; set; } + + public class ContentDataIni : GenericINI + { + public ContentTypes Type { get; set; } + public UgcTagsData Tags { get; set; } + } + } + + public class GenericINI + { + public string Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public Uri Image { get; set; } + } + + public struct UgcTagsData + { + public bool Gore; + public bool Horror; + public bool Jumpscare; + public bool Nudity; + public bool Suggestive; + public bool Violence; + public bool ContainsMusic; + public bool ExtremelyBright; + public bool ExtremelyHuge; + public bool ExtremelySmall; + public bool FlashingColors; + public bool FlashingLights; + public bool LoudAudio; + public bool ParticleSystems; + public bool ScreenEffects; + public bool SpawnAudio; + public bool LongRangeAudio; + } +} \ No newline at end of file diff --git a/Assets/ABI.CCK/Scripts/APIConnection.cs.meta b/Assets/ABI.CCK/Scripts/APIConnection.cs.meta new file mode 100755 index 0000000..c5a3c7e --- /dev/null +++ b/Assets/ABI.CCK/Scripts/APIConnection.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b6e98b6775f64bbdb3309a8b58773d81 +timeCreated: 1678553770 \ No newline at end of file diff --git a/Assets/ABI.CCK/Scripts/CVRAdvancedAvatarSettings.cs b/Assets/ABI.CCK/Scripts/CVRAdvancedAvatarSettings.cs index 3a46c92..8ec1ad9 100755 --- a/Assets/ABI.CCK/Scripts/CVRAdvancedAvatarSettings.cs +++ b/Assets/ABI.CCK/Scripts/CVRAdvancedAvatarSettings.cs @@ -179,6 +179,7 @@ namespace ABI.CCK.Scripts public bool useAnimationClip; public AnimationClip animationClip; + public AnimationClip offAnimationClip; public List gameObjectTargets = new List(); @@ -256,7 +257,14 @@ namespace ABI.CCK.Scripts if (useAnimationClip) { onClip = animationClip; - AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + machineName + "_Toggle_Off.anim"); + if (offAnimationClip != null) + { + offClip = offAnimationClip; + } + else + { + AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + machineName + "_Toggle_Off.anim"); + } } else { AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + machineName + "_Toggle_Off.anim"); diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_AnimatorDriverEditor.cs b/Assets/ABI.CCK/Scripts/Editor/CCK_AnimatorDriverEditor.cs new file mode 100755 index 0000000..c20b84b --- /dev/null +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_AnimatorDriverEditor.cs @@ -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 animatorParamNames = new List(); + private List animatorParamNamesDisplay = new List(); + private List animatorParamTypes = new List(); + + 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); + } +} \ No newline at end of file diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_AnimatorDriverEditor.cs.meta b/Assets/ABI.CCK/Scripts/Editor/CCK_AnimatorDriverEditor.cs.meta new file mode 100755 index 0000000..7cbc779 --- /dev/null +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_AnimatorDriverEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cf1a3cb4c93d41c9b01fcf9f128fbca2 +timeCreated: 1685439016 \ No newline at end of file diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_BuildManagerWindow.cs b/Assets/ABI.CCK/Scripts/Editor/CCK_BuildManagerWindow.cs index f66ab87..1bd4ecf 100755 --- a/Assets/ABI.CCK/Scripts/Editor/CCK_BuildManagerWindow.cs +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_BuildManagerWindow.cs @@ -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("Assets/ABI.CCK/GUIAssets/CCK_UploaderHead.prefab")); OnGuiUpdater up = ui.GetComponentInChildren(); if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRAvatar.prefab"))up.asset = Resources.Load("Cache/_CVRAvatar").GetComponent(); + if (File.Exists(Application.dataPath + $"/ABI.CCK/Resources/Cache/CVRAvatar_{CCK_BuildUtility.upload_id}_{randomNum}.prefab"))up.asset = Resources.Load($"Cache/CVRAvatar_{CCK_BuildUtility.upload_id}_{randomNum}").GetComponent(); if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab"))up.asset = Resources.Load("Cache/_CVRSpawnable").GetComponent(); + if (File.Exists(Application.dataPath + $"/ABI.CCK/Resources/Cache/CVRSpawnable_{CCK_BuildUtility.upload_id}_{randomNum}.prefab"))up.asset = Resources.Load($"Cache/CVRSpawnable_{CCK_BuildUtility.upload_id}_{randomNum}").GetComponent(); if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab"))up.asset = Resources.Load("Cache/_CVRWorld").GetComponent(); } } @@ -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 response = await APIConnection.MakeRequest("cck/userinfo"); - if (response.IsSuccessStatusCode) + if (response != null) + { + if (response.Data != null) { - string result = await response.Content.ReadAsStringAsync(); - BaseResponse usr = Abi.Newtonsoft.Json.JsonConvert.DeserializeObject>(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 - { - 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); - } - } } \ No newline at end of file diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_BuildUtility.cs b/Assets/ABI.CCK/Scripts/Editor/CCK_BuildUtility.cs index 30ea1a2..1aa6f27 100755 --- a/Assets/ABI.CCK/Scripts/Editor/CCK_BuildUtility.cs +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_BuildUtility.cs @@ -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(); @@ -33,17 +38,35 @@ namespace ABI.CCK.Scripts.Editor //CVRAssetInfo info = avatarCopy.GetComponent(); 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 response = await APIConnection.MakeRequest("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(); var spawnable = s.GetComponent(); 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 response = await APIConnection.MakeRequest("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(); - 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(); + + if (string.IsNullOrEmpty(info.objectId)) + { +#if UNITY_EDITOR + APIConnection.Initialize(EditorPrefs.GetString("m_ABI_Username"), EditorPrefs.GetString("m_ABI_Key")); +#endif + + APIConnection.BaseResponse response = await APIConnection.MakeRequest("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(); - 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(); diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_CVRAnimatorDriverEditor.cs b/Assets/ABI.CCK/Scripts/Editor/CCK_CVRAnimatorDriverEditor.cs index c5f8391..64ac452 100755 --- a/Assets/ABI.CCK/Scripts/Editor/CCK_CVRAnimatorDriverEditor.cs +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_CVRAnimatorDriverEditor.cs @@ -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++; + } } } diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_CVRAvatarEditor.cs b/Assets/ABI.CCK/Scripts/Editor/CCK_CVRAvatarEditor.cs index 7370a11..9f47d49 100755 --- a/Assets/ABI.CCK/Scripts/Editor/CCK_CVRAvatarEditor.cs +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_CVRAvatarEditor.cs @@ -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 { diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_CVRInteractableEditor.cs b/Assets/ABI.CCK/Scripts/Editor/CCK_CVRInteractableEditor.cs index 67a9f60..11e9d61 100755 --- a/Assets/ABI.CCK/Scripts/Editor/CCK_CVRInteractableEditor.cs +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_CVRInteractableEditor.cs @@ -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( diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_CVR_VideoPlayerEditor.cs b/Assets/ABI.CCK/Scripts/Editor/CCK_CVR_VideoPlayerEditor.cs index e580f75..f730de4 100755 --- a/Assets/ABI.CCK/Scripts/Editor/CCK_CVR_VideoPlayerEditor.cs +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_CVR_VideoPlayerEditor.cs @@ -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 } diff --git a/Assets/ABI.CCK/Scripts/Editor/CCK_Init.cs b/Assets/ABI.CCK/Scripts/Editor/CCK_Init.cs index e5aa217..670ac10 100755 --- a/Assets/ABI.CCK/Scripts/Editor/CCK_Init.cs +++ b/Assets/ABI.CCK/Scripts/Editor/CCK_Init.cs @@ -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 ) diff --git a/Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeUploaderMaster.cs b/Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeUploaderMaster.cs index e843c8a..59ee6af 100755 --- a/Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeUploaderMaster.cs +++ b/Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeUploaderMaster.cs @@ -33,17 +33,17 @@ namespace ABI.CCK.Scripts.Runtime var overwritePic = string.Empty; if (!File.Exists($"{Application.persistentDataPath}/bundle.png")) gameObject.GetComponent().SaveTexture(updater.camObj.GetComponent(), updater.tex); - StartCoroutine(UploadAssetAndSendInformation(updater.asset.GetComponent().objectId, type.ToString(), sfwLevel, updater.assetName.text, updater.assetDesc.text, updater.dontOverridePicture.isOn)); + StartCoroutine(UploadAssetAndSendInformation(updater.asset.objectId, type.ToString(), sfwLevel, updater.assetName.text, updater.assetDesc.text, updater.dontOverridePicture.isOn, updater.asset.randomNum)); } - private IEnumerator UploadAssetAndSendInformation(string contentId, string type, string sfwLevel, string assetName, string assetDesc, bool overwritePic) + private IEnumerator UploadAssetAndSendInformation(string contentId, string type, string sfwLevel, string assetName, string assetDesc, bool overwritePic, string randomNum) { string[] path = null; if (type == "Avatar") { path = new string[3]; - path[0] = $"file://{Application.persistentDataPath}/bundle.cvravatar"; - path[1] = $"file://{Application.persistentDataPath}/bundle.cvravatar.manifest"; + path[0] = $"file://{Application.persistentDataPath}/cvravatar_{contentId}_{randomNum}.cvravatar"; + path[1] = $"file://{Application.persistentDataPath}/cvravatar_{contentId}_{randomNum}.cvravatar.manifest"; path[2] = $"file://{Application.persistentDataPath}/bundle.png"; } if (type == "World") @@ -58,8 +58,8 @@ namespace ABI.CCK.Scripts.Runtime if (type == "Spawnable") { path = new string[3]; - path[0] = $"file://{Application.persistentDataPath}/bundle.cvrprop"; - path[1] = $"file://{Application.persistentDataPath}/bundle.cvrprop.manifest"; + path[0] = $"file://{Application.persistentDataPath}/cvrspawnable_{contentId}_{randomNum}.cvrprop"; + path[1] = $"file://{Application.persistentDataPath}/cvrspawnable_{contentId}_{randomNum}.cvrprop.manifest"; path[2] = $"file://{Application.persistentDataPath}/bundle.png"; } @@ -77,6 +77,13 @@ namespace ABI.CCK.Scripts.Runtime form.AddField("ContentDescription", assetDesc); form.AddField("ContentChangelog", updater.assetChangelog.text); +#if PLATFORM_ANDROID + form.AddField("Platform", "android_standalone"); +#else + form.AddField("Platform", "pc_standalone"); +#endif + form.AddField("CompatibilityVersion", Application.unityVersion.Contains("2021") ? 2 : 1); + if (updater.LoudAudio.isOn) form.AddField("Tag_LoudAudio", 1); if (updater.LongRangeAudio.isOn) form.AddField("Tag_LongRangeAudio", 1); if (updater.ContainsMusic.isOn) form.AddField("Tag_ContainsMusic", 1); diff --git a/Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeVariableStream.cs b/Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeVariableStream.cs index 0d938e2..091fd2c 100755 --- a/Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeVariableStream.cs +++ b/Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeVariableStream.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Net.Http; using System.Text; +using System.Threading.Tasks; using Abi.Newtonsoft.Json; using UnityEditor; using UnityEngine; @@ -19,164 +20,77 @@ namespace ABI.CCK.Scripts.Runtime { OnGuiUpdater updater = gameObject.GetComponent(); string type = updater.asset.type.ToString(); + string uploadRegion = "0"; +#if UNITY_EDITOR + APIConnection.Initialize(EditorPrefs.GetString("m_ABI_Username"), EditorPrefs.GetString("m_ABI_Key")); + EditorPrefs.GetInt("ABI_PREF_UPLOAD_REGION").ToString(); +#endif + + Task> task = Task.Run(() => APIConnection.MakeRequest( + $"cck/contentInfo/{type}/{updater.asset.objectId}?platform=pc_standalone®ion={uploadRegion}")); + + while (!task.IsCompleted) yield return null; - using (HttpClient httpclient = new HttpClient()) + APIConnection.BaseResponse response = task.Result; + + if (response != null) { - HttpResponseMessage response; - response = httpclient.PostAsync( - "https://api.abinteractive.net/1/cck/parameterStream", - new StringContent(JsonConvert.SerializeObject(new - { - ContentType = type, ContentId = updater.asset.objectId, -#if UNITY_EDITOR - Username = EditorPrefs.GetString("m_ABI_Username"), - AccessKey = EditorPrefs.GetString("m_ABI_Key"), - UploadRegion = EditorPrefs.GetInt("ABI_PREF_UPLOAD_REGION").ToString() -#endif - }), - Encoding.UTF8, "application/json") - ).GetAwaiter().GetResult(); - - if (response.IsSuccessStatusCode) + if (response.Data != null) { - string result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); - BaseResponse streamResponse = Abi.Newtonsoft.Json.JsonConvert .DeserializeObject>(result); + updater.UploadLocation = response.Data.UploadLocation; + Debug.Log($"Upload Location: {updater.UploadLocation}"); + updater.assetName.text = response.Data.ContentData.Name; + updater.assetDesc.text = response.Data.ContentData.Description; - if (streamResponse == null || streamResponse.Data == null) - { -#if UNITY_EDITOR - EditorUtility.ClearProgressBar(); - if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", - "Request failed. Unable to connect to the Gateway. The Gateway might be unavailable. Check https://status.abinteractive.net for more info.", - "Okay")) - { - EditorApplication.isPlaying = false; - } -#endif - yield break; - } + updater.LoudAudio.isOn = response.Data.ContentData.Tags.LoudAudio; + updater.LongRangeAudio.isOn = response.Data.ContentData.Tags.LongRangeAudio; + updater.SpawnAudio.isOn = response.Data.ContentData.Tags.SpawnAudio; + updater.ContainsMusic.isOn = response.Data.ContentData.Tags.ContainsMusic; - if (!streamResponse.Data.HasPermission) - { -#if UNITY_EDITOR - EditorUtility.ClearProgressBar(); - if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", - "Request failed. The provided content ID does not belong to your account.", "Okay")) - { - EditorApplication.isPlaying = false; - } -#endif - yield break; - } + updater.ScreenEffects.isOn = response.Data.ContentData.Tags.ScreenEffects; + updater.FlashingColors.isOn = response.Data.ContentData.Tags.FlashingColors; + updater.FlashingLights.isOn = response.Data.ContentData.Tags.FlashingLights; + updater.ExtremelyBright.isOn = response.Data.ContentData.Tags.ExtremelyBright; + updater.ParticleSystems.isOn = response.Data.ContentData.Tags.ParticleSystems; - if (streamResponse.Data.IsAtUploadLimit) - { -#if UNITY_EDITOR - EditorUtility.ClearProgressBar(); - if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", - "Request failed. Your account has reached the upload limit. Please consider buying the Unlocked account.", - "Okay")) - { - EditorApplication.isPlaying = false; - } -#endif - } + updater.Violence.isOn = response.Data.ContentData.Tags.Violence; + updater.Gore.isOn = response.Data.ContentData.Tags.Gore; + updater.Horror.isOn = response.Data.ContentData.Tags.Horror; + updater.Jumpscare.isOn = response.Data.ContentData.Tags.Jumpscare; - if (streamResponse.Data.IsBannedFromUploading) - { -#if UNITY_EDITOR - EditorUtility.ClearProgressBar(); - if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", - "Request failed. Your upload permissions are suspended. For more information, consult your moderation profile in the ABI community hub.", - "Okay")) - { - EditorApplication.isPlaying = false; - } -#endif - } + updater.ExcessivelySmall.isOn = response.Data.ContentData.Tags.ExtremelySmall; + updater.ExcessivelyHuge.isOn = response.Data.ContentData.Tags.ExtremelyHuge; - updater.UploadLocation = streamResponse.Data.UploadLocation; - - updater.assetName.text = streamResponse.Data.ObjectName; - updater.assetDesc.text = streamResponse.Data.ObjectDescription; - - updater.LoudAudio.isOn = streamResponse.Data.LoudAudio; - updater.LongRangeAudio.isOn = streamResponse.Data.LongRangeAudio; - updater.SpawnAudio.isOn = streamResponse.Data.SpawnAudio; - updater.ContainsMusic.isOn = streamResponse.Data.ContainsMusic; - - updater.ScreenEffects.isOn = streamResponse.Data.ScreenFx; - updater.FlashingColors.isOn = streamResponse.Data.FlashingColors; - updater.FlashingLights.isOn = streamResponse.Data.FlashingLights; - updater.ExtremelyBright.isOn = streamResponse.Data.ExtremelyBright; - updater.ParticleSystems.isOn = streamResponse.Data.ParticleSystems; - - updater.Violence.isOn = streamResponse.Data.Violence; - updater.Gore.isOn = streamResponse.Data.Gore; - updater.Horror.isOn = streamResponse.Data.Horror; - updater.Jumpscare.isOn = streamResponse.Data.Jumpscare; - - updater.ExcessivelySmall.isOn = streamResponse.Data.ExtremelySmall; - updater.ExcessivelyHuge.isOn = streamResponse.Data.ExtremelyHuge; - - updater.Suggestive.isOn = streamResponse.Data.Suggestive; - updater.Nudity.isOn = streamResponse.Data.Nudity; + updater.Suggestive.isOn = response.Data.ContentData.Tags.Suggestive; + updater.Nudity.isOn = response.Data.ContentData.Tags.Nudity; } + else + { +#if UNITY_EDITOR + EditorUtility.ClearProgressBar(); + if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", + response.Message, "Okay")) + { + EditorApplication.isPlaying = false; + } +#endif + yield break; + } + } + else + { +#if UNITY_EDITOR + EditorUtility.ClearProgressBar(); + if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", + "An Error occured while uploading. Please try again later.", "Okay")) + { + EditorApplication.isPlaying = false; + } +#endif + yield break; } } } - - [Serializable] - public class VariableStreamResponse - { - public bool HasPermission { get; set; } - public bool IsAtUploadLimit { get; set; } - public bool IsBannedFromUploading { get; set; } - - public string UploadLocation { get; set; } - - public string ObjectName { get; set; } - public string ObjectDescription { get; set; } - - public bool LoudAudio { get; set; } - public bool LongRangeAudio { get; set; } - public bool SpawnAudio { get; set; } - public bool ContainsMusic { get; set; } - - public bool ScreenFx { get; set; } - public bool FlashingColors { get; set; } - public bool FlashingLights { get; set; } - public bool ExtremelyBright { get; set; } - public bool ParticleSystems { get; set; } - - public bool Violence { get; set; } - public bool Gore { get; set; } - public bool Horror { get; set; } - public bool Jumpscare { get; set; } - - public bool ExtremelySmall { get; set; } - public bool ExtremelyHuge { get; set; } - - public bool Suggestive { get; set; } - public bool Nudity { get; set; } - } - - public class BaseResponse - { - 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); - } - } } \ No newline at end of file diff --git a/Assets/ABI.CCK/Scripts/Runtime/OnGuiUpdater.cs b/Assets/ABI.CCK/Scripts/Runtime/OnGuiUpdater.cs index 61e2662..53acc58 100755 --- a/Assets/ABI.CCK/Scripts/Runtime/OnGuiUpdater.cs +++ b/Assets/ABI.CCK/Scripts/Runtime/OnGuiUpdater.cs @@ -114,7 +114,7 @@ namespace ABI.CCK.Scripts.Runtime camObj.name = "ShotCam for CVR CCK"; camObj.transform.rotation = new Quaternion(0,180,0,0); CVRAvatar avatar = asset.GetComponent(); - if (asset.type == CVRAssetInfo.AssetType.Avatar) camObj.transform.position = new Vector3(avatar.viewPosition.x, avatar.viewPosition.y, avatar.viewPosition.z *= 5f); + if (avatar != null && asset.type == CVRAssetInfo.AssetType.Avatar) camObj.transform.position = new Vector3(avatar.viewPosition.x, avatar.viewPosition.y, avatar.viewPosition.z *= 5f); var cam = camObj.AddComponent(); cam.aspect = 1f; cam.nearClipPlane = 0.01f; @@ -125,21 +125,23 @@ namespace ABI.CCK.Scripts.Runtime #if UNITY_EDITOR #endif + + string content_id = asset.objectId; if (type == CVRAssetInfo.AssetType.Avatar) { - assetFileSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.cvravatar").Length); + assetFileSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + $"/cvravatar_{content_id}_{asset.randomNum}.cvravatar").Length); assetImageFileSizeText.text = "N/A"; - assetFileManifestSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.cvravatar.manifest").Length); + assetFileManifestSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + $"/cvravatar_{content_id}_{asset.randomNum}.cvravatar.manifest").Length); assetFilePano1SizeText.text = "N/A"; assetFilePano4SizeText.text = "N/A"; } if (type == CVRAssetInfo.AssetType.Spawnable) { - assetFileSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.cvrprop").Length); + assetFileSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + $"/cvrspawnable_{content_id}_{asset.randomNum}.cvrprop").Length); assetImageFileSizeText.text = ""; - assetFileManifestSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.cvrprop.manifest").Length); + assetFileManifestSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + $"/cvrspawnable_{content_id}_{asset.randomNum}.cvrprop.manifest").Length); assetFilePano1SizeText.text = "N/A"; assetFilePano4SizeText.text = "N/A"; } diff --git a/Assets/ABI.CCK/Scripts/ShaderCompatibilityPreprocessor.cs b/Assets/ABI.CCK/Scripts/ShaderCompatibilityPreprocessor.cs index ad15c79..6a5d006 100755 --- a/Assets/ABI.CCK/Scripts/ShaderCompatibilityPreprocessor.cs +++ b/Assets/ABI.CCK/Scripts/ShaderCompatibilityPreprocessor.cs @@ -16,6 +16,9 @@ public class ShaderCompatibilityPreprocessor : IPreprocessShaders public void OnProcessShader(Shader shader, ShaderSnippetData snippet, IList data) { +#if UNITY_2021_1_OR_NEWER + //Do nothing here +#else if(EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64) { List reworkedData = new List(); @@ -47,6 +50,7 @@ public class ShaderCompatibilityPreprocessor : IPreprocessShaders data.Add(entry); } } +#endif } } #endif \ No newline at end of file diff --git a/Assets/ABI.CCK/Textures/24718.renderTexture b/Assets/ABI.CCK/Textures/24718.renderTexture index c44b4bd..34f71a4 100755 Binary files a/Assets/ABI.CCK/Textures/24718.renderTexture and b/Assets/ABI.CCK/Textures/24718.renderTexture differ