upgrade CCK to v3.5
This commit is contained in:
parent
6fe98b333d
commit
3005cfc8aa
43 changed files with 1213 additions and 289 deletions
|
@ -33,17 +33,17 @@ namespace ABI.CCK.Scripts.Runtime
|
|||
var overwritePic = string.Empty;
|
||||
|
||||
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;
|
||||
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);
|
||||
|
|
|
@ -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<OnGuiUpdater>();
|
||||
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<APIConnection.BaseResponse<APIConnection.ContentInfoResponse>> task = Task.Run(() => APIConnection.MakeRequest<APIConnection.ContentInfoResponse>(
|
||||
$"cck/contentInfo/{type}/{updater.asset.objectId}?platform=pc_standalone®ion={uploadRegion}"));
|
||||
|
||||
while (!task.IsCompleted) yield return null;
|
||||
|
||||
using (HttpClient httpclient = new HttpClient())
|
||||
APIConnection.BaseResponse<APIConnection.ContentInfoResponse> 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<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)
|
||||
{
|
||||
#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<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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<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>();
|
||||
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";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue