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,209 @@
using System.Collections.Generic;
using UnityEngine;
namespace ABI.CCK.Components
{
public class AnimatorDriver : StateMachineBehaviour
{
public List<AnimatorDriverTask> EnterTasks = new List<AnimatorDriverTask>();
public List<AnimatorDriverTask> ExitTasks = new List<AnimatorDriverTask>();
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;
}
}
}
}

View file

@ -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:

View file

@ -17,5 +17,8 @@ namespace ABI.CCK.Components
public AssetType type; public AssetType type;
public string objectId; public string objectId;
[HideInInspector]
public string randomNum;
} }
} }

View file

@ -1,4 +1,5 @@
using UnityEngine; using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
namespace ABI.CCK.Components namespace ABI.CCK.Components
@ -10,6 +11,7 @@ namespace ABI.CCK.Components
{ {
Bone = 1, Bone = 1,
Tracker = 2, Tracker = 2,
SnappingPoint = 4,
} }
public AttachmentType attachmentType; public AttachmentType attachmentType;
@ -53,6 +55,8 @@ namespace ABI.CCK.Components
public TrackerType trackerType = 0; public TrackerType trackerType = 0;
public List<string> snappingPointTypes = new List<string>();
public bool useFixedPositionOffset = false; public bool useFixedPositionOffset = false;
public bool useFixedRotationOffset = false; public bool useFixedRotationOffset = false;

View file

@ -37,6 +37,8 @@ namespace ABI.CCK.Components
public CVRAvatarVisemeMode visemeMode = CVRAvatarVisemeMode.Visemes; public CVRAvatarVisemeMode visemeMode = CVRAvatarVisemeMode.Visemes;
public int visemeSmoothing = 50;
public string[] visemeBlendshapes = new string[15]; public string[] visemeBlendshapes = new string[15];
[Space] [Header("Avatar customization")] [Space] [Space] [Header("Avatar customization")] [Space]
@ -82,8 +84,8 @@ namespace ABI.CCK.Components
FlashingLights = 16, FlashingLights = 16,
Violence = 32, Violence = 32,
Gore = 64, Gore = 64,
//Suggestive = 128, Suggestive = 128,
//Nudity = 256, Nudity = 256,
Horror = 512 Horror = 512
} }

View file

@ -123,6 +123,11 @@ namespace ABI.CCK.Components
Alpha7 = KeyCode.Alpha7, Alpha7 = KeyCode.Alpha7,
Alpha8 = KeyCode.Alpha8, Alpha8 = KeyCode.Alpha8,
Alpha9 = KeyCode.Alpha9, Alpha9 = KeyCode.Alpha9,
LeftShift = KeyCode.LeftShift,
RightShift = KeyCode.RightShift,
LeftControl = KeyCode.LeftControl,
RightControl = KeyCode.RightControl,
Space = KeyCode.Space,
InputHorizontalNegative = 10000, InputHorizontalNegative = 10000,
InputHorizontalPositive = 10001, InputHorizontalPositive = 10001,
InputVerticalNegative = 10002, InputVerticalNegative = 10002,

View file

@ -29,6 +29,7 @@ namespace ABI.CCK.Components
DisplayWorldDetailPage = 13, DisplayWorldDetailPage = 13,
DisplayInstanceDetailPage = 14, DisplayInstanceDetailPage = 14,
DisplayAvatarDetailPage = 15, DisplayAvatarDetailPage = 15,
DisplaySpawnableDetailPage = 37,
SitAtPosition = 16, SitAtPosition = 16,
MethodCall = 21, MethodCall = 21,
SetSpawnableValue = 22, SetSpawnableValue = 22,

View file

@ -24,12 +24,15 @@ namespace ABI.CCK.Components
[Header("Events")] [Header("Events")]
public UnityEvent playerDownEvent = new UnityEvent(); public UnityEvent playerDownEvent = new UnityEvent();
public UnityEvent playerHitEvent = new UnityEvent();
public UnityEvent playerRespawnEvent = new UnityEvent(); public UnityEvent playerRespawnEvent = new UnityEvent();
public UnityEvent playerRevitalizeEvent = new UnityEvent(); public UnityEvent playerRevitalizeEvent = new UnityEvent();
[Header("PVP Events")] [Header("PVP Events")]
public UnityEvent playerDownedEvent = new UnityEvent(); public UnityEvent playerDownedEvent = new UnityEvent();
public UnityEvent downedAnotherPlayerEvent = new UnityEvent(); public UnityEvent downedAnotherPlayerEvent = new UnityEvent();
public UnityEvent playerGotHitEvent = new UnityEvent();
public UnityEvent hitAnotherPlayerEvent = new UnityEvent();
private void Reset() private void Reset()
{ {

View file

@ -103,5 +103,7 @@ namespace ABI.CCK.Components
public UnityEvent teamLeaveEvent = new UnityEvent(); public UnityEvent teamLeaveEvent = new UnityEvent();
public UnityEvent teamWinRoundEvent = new UnityEvent(); public UnityEvent teamWinRoundEvent = new UnityEvent();
public UnityEvent teamWinGameEvent = new UnityEvent(); public UnityEvent teamWinGameEvent = new UnityEvent();
public UnityEvent teamMemberReadyEvent = new UnityEvent();
public UnityEvent teamMemberUnReadyEvent = new UnityEvent();
} }
} }

View file

@ -26,6 +26,15 @@ namespace ABI.CCK.Components
public float firingRate = 1f; public float firingRate = 1f;
public float reloadTime = 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() public void Shoot()
{ {

View file

@ -11,11 +11,16 @@ namespace ABI.CCK.Components
{ {
Destroy = 0, Destroy = 0,
RespawnAfterTime = 1, RespawnAfterTime = 1,
RespawnOnRoundStart = 2,
RespawnOnRoundEnd = 3,
RespawnOnGameStart = 4,
RespawnOnGameEnd = 5,
} }
[Header("Down Behavior")] [Header("Down Behavior")]
public DownBehavior downBehavior = DownBehavior.Destroy; public DownBehavior downBehavior = DownBehavior.Destroy;
public float respawnTime = 10f; public float respawnTime = 10f;
public Transform respawnPoint; public Transform respawnPoint;
public GameInstanceController connectedGameInstance;
[Header("Events")] [Header("Events")]
public UnityEvent downEvent = new UnityEvent(); public UnityEvent downEvent = new UnityEvent();

View file

@ -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";
}
}

View file

@ -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:

View file

@ -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);
}
}
}

View file

@ -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:

View file

@ -17079,7 +17079,7 @@ MonoBehaviour:
m_HorizontalOverflow: 1 m_HorizontalOverflow: 1
m_VerticalOverflow: 1 m_VerticalOverflow: 1
m_LineSpacing: 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 --- !u!1 &8389522060313083026
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

Binary file not shown.

Binary file not shown.

View file

@ -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<BaseResponse<T>> MakeRequest<T>(string url, Object data = null, string apiVersion = null, bool put = false)
{
if (!_initialized) return default(BaseResponse<T>);
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<BaseResponse<T>>(await response.Content.ReadAsStringAsync());
}
else
{
Debug.LogError($"Result from API Request {currentRequestUrl} returned {response.StatusCode}");
}
try
{
BaseResponse<T> res = JsonConvert.DeserializeObject<BaseResponse<T>>(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<T>);
}
//Responses
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);
}
}
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;
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b6e98b6775f64bbdb3309a8b58773d81
timeCreated: 1678553770

View file

@ -179,6 +179,7 @@ namespace ABI.CCK.Scripts
public bool useAnimationClip; public bool useAnimationClip;
public AnimationClip animationClip; public AnimationClip animationClip;
public AnimationClip offAnimationClip;
public List<CVRAdvancedSettingsTargetEntryGameObject> gameObjectTargets = public List<CVRAdvancedSettingsTargetEntryGameObject> gameObjectTargets =
new List<CVRAdvancedSettingsTargetEntryGameObject>(); new List<CVRAdvancedSettingsTargetEntryGameObject>();
@ -256,8 +257,15 @@ namespace ABI.CCK.Scripts
if (useAnimationClip) { if (useAnimationClip) {
onClip = animationClip; onClip = animationClip;
if (offAnimationClip != null)
{
offClip = offAnimationClip;
}
else
{
AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + machineName + "_Toggle_Off.anim"); AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + machineName + "_Toggle_Off.anim");
} }
}
else { else {
AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + machineName + "_Toggle_Off.anim"); AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + machineName + "_Toggle_Off.anim");
AssetDatabase.CreateAsset(onClip, folderPath + "/Anim_" + machineName + "_Toggle_On.anim"); AssetDatabase.CreateAsset(onClip, folderPath + "/Anim_" + machineName + "_Toggle_On.anim");

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] [InitializeOnLoad]
public class CCK_BuildManagerWindow : EditorWindow public class CCK_BuildManagerWindow : EditorWindow
{ {
public static string Version = "3.4 RELEASE"; public static string Version = "3.5 RELEASE";
public static int BuildID = 90; public static int BuildID = 98;
private const string CCKVersion = "3.4 RELEASE (Build 92)"; private const string CCKVersion = "3.5 RELEASE (Build 98)";
private string[] SupportedUnityVersions = new[] 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.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.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.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; string _username;
@ -108,13 +112,41 @@ namespace ABI.CCK.Scripts.Editor
{ {
EditorPrefs.SetBool("m_ABI_isBuilding", false); EditorPrefs.SetBool("m_ABI_isBuilding", false);
EditorPrefs.SetString("m_ABI_TempVersion", Version); 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"); string[] filePaths = Directory.GetFiles(Application.dataPath + "/ABI.CCK/Resources/Cache/", "*.prefab");
if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab")) File.Delete(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab"); foreach (string filePath in filePaths)
if (File.Exists(Application.persistentDataPath + "/bundle.cvravatar")) File.Delete(Application.persistentDataPath + "/bundle.cvravatar"); {
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.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")) 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")) 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.cvrworld.manifest")) File.Delete(Application.persistentDataPath + "/bundle.cvrworld.manifest");
if (File.Exists(Application.persistentDataPath + "/bundle.png")) File.Delete(Application.persistentDataPath + "/bundle.png"); 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")) 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")); var ui = Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>("Assets/ABI.CCK/GUIAssets/CCK_UploaderHead.prefab"));
OnGuiUpdater up = ui.GetComponentInChildren<OnGuiUpdater>(); 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.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.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>(); if (File.Exists(Application.dataPath + "/ABI.CCK/Resources/Cache/_CVRWorld.prefab"))up.asset = Resources.Load<GameObject>("Cache/_CVRWorld").GetComponent<CVRAssetInfo>();
} }
} }
@ -690,25 +727,14 @@ namespace ABI.CCK.Scripts.Editor
{ {
_attemptingToLogin = true; _attemptingToLogin = true;
using (HttpClient httpclient = new HttpClient()) APIConnection.Initialize(_username, _key);
{ APIConnection.BaseResponse<APIConnection.UserinfoResponse> response = await APIConnection.MakeRequest<APIConnection.UserinfoResponse>("cck/userinfo");
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")
);
if (response.IsSuccessStatusCode) if (response != null)
{ {
string result = await response.Content.ReadAsStringAsync(); if (response.Data != null)
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; _apiUserRank = response.Data.UserRank;
Debug.Log("[ABI:CCK] Successfully authenticated as " + _username + " using AlphaLink Public API."); Debug.Log("[ABI:CCK] Successfully authenticated as " + _username + " using AlphaLink Public API.");
EditorPrefs.SetString("m_ABI_Username", _username); EditorPrefs.SetString("m_ABI_Username", _username);
EditorPrefs.SetString("m_ABI_Key", _key); EditorPrefs.SetString("m_ABI_Key", _key);
@ -717,44 +743,14 @@ namespace ABI.CCK.Scripts.Editor
} }
else else
{ {
Debug.Log("[ABI:CCK] Unable to authenticate using provided credentials. API responded with: " + usr.Message + "."); Debug.Log("[ABI:CCK] Unable to authenticate using provided credentials. API responded with: " + response.Message + ".");
_loggedIn = false; _loggedIn = false;
_hasAttemptedToLogin = true; _hasAttemptedToLogin = true;
_username = _key = string.Empty; _username = _key = string.Empty;
} }
} }
else
{
Debug.LogError("[ABI:CCK] Web Request Error while trying to authenticate.");
}
}
_attemptingToLogin = false; _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;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using ABI.CCK.Components; using ABI.CCK.Components;
using UnityEditor; using UnityEditor;
using UnityEditor.SceneManagement; using UnityEditor.SceneManagement;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using Random = System.Random;
namespace ABI.CCK.Scripts.Editor namespace ABI.CCK.Scripts.Editor
{ {
@ -14,7 +17,9 @@ namespace ABI.CCK.Scripts.Editor
public static PreAvatarBundleEvent PreAvatarBundleEvent = new PreAvatarBundleEvent(); public static PreAvatarBundleEvent PreAvatarBundleEvent = new PreAvatarBundleEvent();
public static PrePropBundleEvent PrePropBundleEvent = new PrePropBundleEvent(); public static PrePropBundleEvent PrePropBundleEvent = new PrePropBundleEvent();
public static void BuildAndUploadAvatar(GameObject avatarObject) public static string upload_id = "";
public static async Task BuildAndUploadAvatar(GameObject avatarObject)
{ {
//GameObject avatarCopy = null; //GameObject avatarCopy = null;
var origInfo = avatarObject.GetComponent<CVRAssetInfo>(); var origInfo = avatarObject.GetComponent<CVRAssetInfo>();
@ -33,8 +38,27 @@ namespace ABI.CCK.Scripts.Editor
//CVRAssetInfo info = avatarCopy.GetComponent<CVRAssetInfo>(); //CVRAssetInfo info = avatarCopy.GetComponent<CVRAssetInfo>();
if (string.IsNullOrEmpty(origInfo.objectId)) if (string.IsNullOrEmpty(origInfo.objectId))
{ {
origInfo.objectId = Guid.NewGuid().ToString(); #if UNITY_EDITOR
//origInfo.guid = info.guid; 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)
{
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);
try try
{ {
PrefabUtility.ApplyPrefabInstance(avatarObject, InteractionMode.UserAction); PrefabUtility.ApplyPrefabInstance(avatarObject, InteractionMode.UserAction);
@ -43,7 +67,6 @@ namespace ABI.CCK.Scripts.Editor
{ {
Debug.Log("[CCK:BuildUtility] Object is not a prefab. No need to Apply To Instance."); Debug.Log("[CCK:BuildUtility] Object is not a prefab. No need to Apply To Instance.");
} }
}
PreAvatarBundleEvent.Invoke(avatarObject); PreAvatarBundleEvent.Invoke(avatarObject);
@ -51,7 +74,10 @@ namespace ABI.CCK.Scripts.Editor
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
if (!Application.unityVersion.Contains("2021"))
PrefabUtility.SaveAsPrefabAsset(avatarObject, "Assets/ABI.CCK/Resources/Cache/_CVRAvatar.prefab"); 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); //GameObject.DestroyImmediate(avatarCopy);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
@ -59,11 +85,19 @@ namespace ABI.CCK.Scripts.Editor
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
AssetBundleBuild assetBundleBuild = new AssetBundleBuild(); AssetBundleBuild assetBundleBuild = new AssetBundleBuild();
if (!Application.unityVersion.Contains("2021"))
assetBundleBuild.assetNames = new[] {"Assets/ABI.CCK/Resources/Cache/_CVRAvatar.prefab"}; assetBundleBuild.assetNames = new[] {"Assets/ABI.CCK/Resources/Cache/_CVRAvatar.prefab"};
assetBundleBuild.assetBundleName = "bundle.cvravatar"; 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}, BuildPipeline.BuildAssetBundles(Application.persistentDataPath, new[] {assetBundleBuild},
BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget); BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh(); AssetDatabase.Refresh();
@ -71,13 +105,35 @@ namespace ABI.CCK.Scripts.Editor
EditorApplication.isPlaying = true; EditorApplication.isPlaying = true;
} }
public static void BuildAndUploadSpawnable(GameObject s) public static async Task BuildAndUploadSpawnable(GameObject s)
{ {
GameObject sCopy = null; GameObject sCopy = null;
var origInfo = s.GetComponent<CVRAssetInfo>(); var origInfo = s.GetComponent<CVRAssetInfo>();
var spawnable = s.GetComponent<CVRSpawnable>(); var spawnable = s.GetComponent<CVRSpawnable>();
spawnable.spawnableType = CVRSpawnable.SpawnableType.StandaloneSpawnable; 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); PrePropBundleEvent.Invoke(s);
try try
@ -92,10 +148,7 @@ namespace ABI.CCK.Scripts.Editor
} }
CVRAssetInfo info = sCopy.GetComponent<CVRAssetInfo>(); CVRAssetInfo info = sCopy.GetComponent<CVRAssetInfo>();
if (string.IsNullOrEmpty(info.objectId))
{
info.objectId = Guid.NewGuid().ToString();
origInfo.objectId = info.objectId;
try try
{ {
PrefabUtility.ApplyPrefabInstance(s, InteractionMode.UserAction); PrefabUtility.ApplyPrefabInstance(s, InteractionMode.UserAction);
@ -104,13 +157,16 @@ namespace ABI.CCK.Scripts.Editor
{ {
Debug.Log("[CCK:BuildUtility] Object is not a prefab. No need to Apply To Instance."); Debug.Log("[CCK:BuildUtility] Object is not a prefab. No need to Apply To Instance.");
} }
}
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
if (!Application.unityVersion.Contains("2021"))
PrefabUtility.SaveAsPrefabAsset(sCopy, "Assets/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab"); 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); GameObject.DestroyImmediate(sCopy);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
@ -118,11 +174,20 @@ namespace ABI.CCK.Scripts.Editor
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
AssetBundleBuild assetBundleBuild = new AssetBundleBuild(); AssetBundleBuild assetBundleBuild = new AssetBundleBuild();
if (!Application.unityVersion.Contains("2021"))
assetBundleBuild.assetNames = new[] {"Assets/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab"}; assetBundleBuild.assetNames = new[] {"Assets/ABI.CCK/Resources/Cache/_CVRSpawnable.prefab"};
assetBundleBuild.assetBundleName = "bundle.cvrprop"; 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}, BuildPipeline.BuildAssetBundles(Application.persistentDataPath, new[] {assetBundleBuild},
BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget); BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh(); AssetDatabase.Refresh();
@ -130,17 +195,35 @@ namespace ABI.CCK.Scripts.Editor
EditorApplication.isPlaying = true; EditorApplication.isPlaying = true;
} }
public static void BuildAndUploadMapAsset(Scene scene, GameObject descriptor) public static async Task BuildAndUploadMapAsset(Scene scene, GameObject descriptor)
{ {
SetupNetworkUUIDs(); 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.MarkSceneDirty(scene);
EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); 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"); PrefabUtility.SaveAsPrefabAsset(descriptor, "Assets/ABI.CCK/Resources/Cache/_CVRWorld.prefab");
AssetBundleBuild assetBundleBuild = new AssetBundleBuild(); AssetBundleBuild assetBundleBuild = new AssetBundleBuild();
@ -148,7 +231,7 @@ namespace ABI.CCK.Scripts.Editor
assetBundleBuild.assetBundleName = "bundle.cvrworld"; assetBundleBuild.assetBundleName = "bundle.cvrworld";
BuildPipeline.BuildAssetBundles(Application.persistentDataPath, new[] {assetBundleBuild}, BuildPipeline.BuildAssetBundles(Application.persistentDataPath, new[] {assetBundleBuild},
BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget); BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh(); AssetDatabase.Refresh();

View file

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

View file

@ -105,6 +105,9 @@ namespace ABI.CCK.Scripts.Editor
_avatar.visemeMode = (CVRAvatar.CVRAvatarVisemeMode) EditorGUILayout.EnumPopup("Lip Sync Mode", _avatar.visemeMode); _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) if (_avatar.visemeBlendshapes == null || _avatar.visemeBlendshapes.Length != _visemeNames.Length)
_avatar.visemeBlendshapes = new string[_visemeNames.Length]; _avatar.visemeBlendshapes = new string[_visemeNames.Length];
@ -153,7 +156,7 @@ namespace ABI.CCK.Scripts.Editor
if (_avatar.enableAdvancedTagging) 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(); if (taggingList == null) InitializeTaggingList();
taggingList.DoLayoutList(); taggingList.DoLayoutList();
@ -429,7 +432,7 @@ namespace ABI.CCK.Scripts.Editor
float height = 10.50f; float height = 10.50f;
if (gameObjectToggle.useAnimationClip) if (gameObjectToggle.useAnimationClip)
{ {
height -= 1.25f; //height -= 1.25f;
} }
else else
{ {
@ -781,6 +784,15 @@ namespace ABI.CCK.Scripts.Editor
_rect.x += 100; _rect.x += 100;
_rect.width = rect.width - 100; _rect.width = rect.width - 100;
gameObjectToggle.animationClip = (AnimationClip)EditorGUI.ObjectField(_rect, gameObjectToggle.animationClip, typeof(AnimationClip), true); 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 else
{ {

View file

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

View file

@ -133,7 +133,7 @@ public class CCK_CVR_VideoPlayerEditor : Editor
{ {
#region General settings #region General settings
_showGeneral = EditorGUILayout.BeginFoldoutHeaderGroup(_showGeneral, "General"); _showGeneral = EditorGUILayout.Foldout(_showGeneral, "General");
if (_showGeneral) if (_showGeneral)
{ {
_player.syncEnabled = EditorGUILayout.Toggle("Network Sync", _player.syncEnabled); _player.syncEnabled = EditorGUILayout.Toggle("Network Sync", _player.syncEnabled);
@ -170,14 +170,11 @@ public class CCK_CVR_VideoPlayerEditor : Editor
EditorGUILayout.Space(); EditorGUILayout.Space();
} }
EditorGUILayout.EndFoldoutHeaderGroup();
#endregion #endregion
#region Audio settings #region Audio settings
_showAudio = EditorGUILayout.BeginFoldoutHeaderGroup(_showAudio, "Audio"); _showAudio = EditorGUILayout.Foldout(_showAudio, "Audio");
if (_showAudio) if (_showAudio)
{ {
_player.playbackVolume = EditorGUILayout.Slider("Playback Volume", _player.playbackVolume, 0.0f, 1.0f); _player.playbackVolume = EditorGUILayout.Slider("Playback Volume", _player.playbackVolume, 0.0f, 1.0f);
@ -191,14 +188,11 @@ public class CCK_CVR_VideoPlayerEditor : Editor
EditorGUILayout.Space(); EditorGUILayout.Space();
} }
EditorGUILayout.EndFoldoutHeaderGroup();
#endregion #endregion
#region Playlists #region Playlists
_showPlaylists = EditorGUILayout.BeginFoldoutHeaderGroup(_showPlaylists, "Playlists"); _showPlaylists = EditorGUILayout.Foldout(_showPlaylists, "Playlists");
if (_showPlaylists) if (_showPlaylists)
{ {
EditorGUILayout.LabelField(new GUIContent("Play On Awake Object", "Default video to play on start/awake"), new GUIContent(_player.playOnAwakeObject?.videoTitle)); 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.Space();
} }
EditorGUILayout.EndFoldoutHeaderGroup();
#endregion #endregion
#region Events #region Events
_showEvents = EditorGUILayout.BeginFoldoutHeaderGroup(_showEvents, "Events"); _showEvents = EditorGUILayout.BeginFoldoutHeaderGroup(_showEvents, "Events");
if (_showEvents) if (_showEvents)
{ {
serializedObject.Update(); serializedObject.Update();
@ -239,8 +230,6 @@ public class CCK_CVR_VideoPlayerEditor : Editor
EditorGUILayout.Space(); EditorGUILayout.Space();
} }
EditorGUILayout.EndFoldoutHeaderGroup();
#endregion #endregion
} }
} }

View file

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

View file

@ -33,17 +33,17 @@ namespace ABI.CCK.Scripts.Runtime
var overwritePic = string.Empty; var overwritePic = string.Empty;
if (!File.Exists($"{Application.persistentDataPath}/bundle.png")) gameObject.GetComponent<CCK_TexImageCreation>().SaveTexture(updater.camObj.GetComponent<Camera>(), updater.tex); if (!File.Exists($"{Application.persistentDataPath}/bundle.png")) gameObject.GetComponent<CCK_TexImageCreation>().SaveTexture(updater.camObj.GetComponent<Camera>(), updater.tex);
StartCoroutine(UploadAssetAndSendInformation(updater.asset.GetComponent<CVRAssetInfo>().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; string[] path = null;
if (type == "Avatar") if (type == "Avatar")
{ {
path = new string[3]; path = new string[3];
path[0] = $"file://{Application.persistentDataPath}/bundle.cvravatar"; path[0] = $"file://{Application.persistentDataPath}/cvravatar_{contentId}_{randomNum}.cvravatar";
path[1] = $"file://{Application.persistentDataPath}/bundle.cvravatar.manifest"; path[1] = $"file://{Application.persistentDataPath}/cvravatar_{contentId}_{randomNum}.cvravatar.manifest";
path[2] = $"file://{Application.persistentDataPath}/bundle.png"; path[2] = $"file://{Application.persistentDataPath}/bundle.png";
} }
if (type == "World") if (type == "World")
@ -58,8 +58,8 @@ namespace ABI.CCK.Scripts.Runtime
if (type == "Spawnable") if (type == "Spawnable")
{ {
path = new string[3]; path = new string[3];
path[0] = $"file://{Application.persistentDataPath}/bundle.cvrprop"; path[0] = $"file://{Application.persistentDataPath}/cvrspawnable_{contentId}_{randomNum}.cvrprop";
path[1] = $"file://{Application.persistentDataPath}/bundle.cvrprop.manifest"; path[1] = $"file://{Application.persistentDataPath}/cvrspawnable_{contentId}_{randomNum}.cvrprop.manifest";
path[2] = $"file://{Application.persistentDataPath}/bundle.png"; path[2] = $"file://{Application.persistentDataPath}/bundle.png";
} }
@ -77,6 +77,13 @@ namespace ABI.CCK.Scripts.Runtime
form.AddField("ContentDescription", assetDesc); form.AddField("ContentDescription", assetDesc);
form.AddField("ContentChangelog", updater.assetChangelog.text); 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.LoudAudio.isOn) form.AddField("Tag_LoudAudio", 1);
if (updater.LongRangeAudio.isOn) form.AddField("Tag_LongRangeAudio", 1); if (updater.LongRangeAudio.isOn) form.AddField("Tag_LongRangeAudio", 1);
if (updater.ContainsMusic.isOn) form.AddField("Tag_ContainsMusic", 1); if (updater.ContainsMusic.isOn) form.AddField("Tag_ContainsMusic", 1);

View file

@ -2,6 +2,7 @@ using System;
using System.Collections; using System.Collections;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks;
using Abi.Newtonsoft.Json; using Abi.Newtonsoft.Json;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -19,164 +20,77 @@ namespace ABI.CCK.Scripts.Runtime
{ {
OnGuiUpdater updater = gameObject.GetComponent<OnGuiUpdater>(); OnGuiUpdater updater = gameObject.GetComponent<OnGuiUpdater>();
string type = updater.asset.type.ToString(); string type = updater.asset.type.ToString();
string uploadRegion = "0";
using (HttpClient httpclient = new HttpClient())
{
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 #if UNITY_EDITOR
Username = EditorPrefs.GetString("m_ABI_Username"), APIConnection.Initialize(EditorPrefs.GetString("m_ABI_Username"), EditorPrefs.GetString("m_ABI_Key"));
AccessKey = EditorPrefs.GetString("m_ABI_Key"), EditorPrefs.GetInt("ABI_PREF_UPLOAD_REGION").ToString();
UploadRegion = EditorPrefs.GetInt("ABI_PREF_UPLOAD_REGION").ToString()
#endif #endif
}),
Encoding.UTF8, "application/json")
).GetAwaiter().GetResult();
if (response.IsSuccessStatusCode) Task<APIConnection.BaseResponse<APIConnection.ContentInfoResponse>> task = Task.Run(() => APIConnection.MakeRequest<APIConnection.ContentInfoResponse>(
$"cck/contentInfo/{type}/{updater.asset.objectId}?platform=pc_standalone&region={uploadRegion}"));
while (!task.IsCompleted) yield return null;
APIConnection.BaseResponse<APIConnection.ContentInfoResponse> response = task.Result;
if (response != null)
{ {
string result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (response.Data != null)
BaseResponse<VariableStreamResponse> streamResponse = Abi.Newtonsoft.Json.JsonConvert .DeserializeObject<BaseResponse<VariableStreamResponse>>(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) 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;
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;
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;
updater.ExcessivelySmall.isOn = response.Data.ContentData.Tags.ExtremelySmall;
updater.ExcessivelyHuge.isOn = response.Data.ContentData.Tags.ExtremelyHuge;
updater.Suggestive.isOn = response.Data.ContentData.Tags.Suggestive;
updater.Nudity.isOn = response.Data.ContentData.Tags.Nudity;
}
else
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
EditorUtility.ClearProgressBar(); EditorUtility.ClearProgressBar();
if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", 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.", response.Message, "Okay"))
"Okay"))
{ {
EditorApplication.isPlaying = false; EditorApplication.isPlaying = false;
} }
#endif #endif
yield break; yield break;
} }
}
if (!streamResponse.Data.HasPermission) else
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
EditorUtility.ClearProgressBar(); EditorUtility.ClearProgressBar();
if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK",
"Request failed. The provided content ID does not belong to your account.", "Okay")) "An Error occured while uploading. Please try again later.", "Okay"))
{ {
EditorApplication.isPlaying = false; EditorApplication.isPlaying = false;
} }
#endif #endif
yield break; yield break;
} }
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
}
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.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;
}
}
}
}
[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<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

@ -114,7 +114,7 @@ namespace ABI.CCK.Scripts.Runtime
camObj.name = "ShotCam for CVR CCK"; camObj.name = "ShotCam for CVR CCK";
camObj.transform.rotation = new Quaternion(0,180,0,0); camObj.transform.rotation = new Quaternion(0,180,0,0);
CVRAvatar avatar = asset.GetComponent<CVRAvatar>(); CVRAvatar avatar = asset.GetComponent<CVRAvatar>();
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<Camera>(); var cam = camObj.AddComponent<Camera>();
cam.aspect = 1f; cam.aspect = 1f;
cam.nearClipPlane = 0.01f; cam.nearClipPlane = 0.01f;
@ -126,20 +126,22 @@ namespace ABI.CCK.Scripts.Runtime
#endif #endif
string content_id = asset.objectId;
if (type == CVRAssetInfo.AssetType.Avatar) 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"; 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"; assetFilePano1SizeText.text = "N/A";
assetFilePano4SizeText.text = "N/A"; assetFilePano4SizeText.text = "N/A";
} }
if (type == CVRAssetInfo.AssetType.Spawnable) 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 = ""; 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"; assetFilePano1SizeText.text = "N/A";
assetFilePano4SizeText.text = "N/A"; assetFilePano4SizeText.text = "N/A";
} }

View file

@ -16,6 +16,9 @@ public class ShaderCompatibilityPreprocessor : IPreprocessShaders
public void OnProcessShader(Shader shader, ShaderSnippetData snippet, IList<ShaderCompilerData> data) public void OnProcessShader(Shader shader, ShaderSnippetData snippet, IList<ShaderCompilerData> data)
{ {
#if UNITY_2021_1_OR_NEWER
//Do nothing here
#else
if(EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64) if(EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64)
{ {
List<ShaderCompilerData> reworkedData = new List<ShaderCompilerData>(); List<ShaderCompilerData> reworkedData = new List<ShaderCompilerData>();
@ -47,6 +50,7 @@ public class ShaderCompatibilityPreprocessor : IPreprocessShaders
data.Add(entry); data.Add(entry);
} }
} }
#endif
} }
} }
#endif #endif