init
This commit is contained in:
commit
c7d8c303a6
499 changed files with 2349700 additions and 0 deletions
205
Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeUploaderMaster.cs
Executable file
205
Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeUploaderMaster.cs
Executable file
|
@ -0,0 +1,205 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using ABI.CCK.Components;
|
||||
using ABI.CCK.Scripts;
|
||||
using Abi.Newtonsoft.Json;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace ABI.CCK.Scripts.Runtime
|
||||
{
|
||||
public class CCK_RuntimeUploaderMaster : MonoBehaviour
|
||||
{
|
||||
public OnGuiUpdater updater;
|
||||
private UnityWebRequest req;
|
||||
|
||||
public bool isUploading;
|
||||
private bool _stateTransfer = false;
|
||||
public float progress = 0f;
|
||||
|
||||
public string encryption;
|
||||
|
||||
public void StartUpload()
|
||||
{
|
||||
//Build string
|
||||
var type = updater.asset.type;
|
||||
var sfwLevel = string.Empty;
|
||||
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));
|
||||
}
|
||||
|
||||
private IEnumerator UploadAssetAndSendInformation(string contentId, string type, string sfwLevel, string assetName, string assetDesc, bool overwritePic)
|
||||
{
|
||||
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[2] = $"file://{Application.persistentDataPath}/bundle.png";
|
||||
}
|
||||
if (type == "World")
|
||||
{
|
||||
path = new string[5];
|
||||
path[0] = $"file://{Application.persistentDataPath}/bundle.cvrworld";
|
||||
path[1] = $"file://{Application.persistentDataPath}/bundle.cvrworld.manifest";
|
||||
path[2] = $"file://{Application.persistentDataPath}/bundle.png";
|
||||
path[3] = $"file://{Application.persistentDataPath}/bundle_pano_1024.png";
|
||||
path[4] = $"file://{Application.persistentDataPath}/bundle_pano_4096.png";
|
||||
}
|
||||
if (type == "Spawnable")
|
||||
{
|
||||
path = new string[3];
|
||||
path[0] = $"file://{Application.persistentDataPath}/bundle.cvrprop";
|
||||
path[1] = $"file://{Application.persistentDataPath}/bundle.cvrprop.manifest";
|
||||
path[2] = $"file://{Application.persistentDataPath}/bundle.png";
|
||||
}
|
||||
|
||||
UnityWebRequest[] files = new UnityWebRequest[path.Length];
|
||||
WWWForm form = new WWWForm();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
form.AddField("Username", EditorPrefs.GetString("m_ABI_Username"));
|
||||
form.AddField("AccessKey", EditorPrefs.GetString("m_ABI_Key"));
|
||||
#endif
|
||||
form.AddField("ContentId", contentId);
|
||||
form.AddField("ContentType", type);
|
||||
|
||||
form.AddField("ContentName", assetName);
|
||||
form.AddField("ContentDescription", assetDesc);
|
||||
form.AddField("ContentChangelog", updater.assetChangelog.text);
|
||||
|
||||
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);
|
||||
if (updater.SpawnAudio.isOn) form.AddField("Tag_SpawnAudio", 1);
|
||||
|
||||
if (updater.FlashingColors.isOn) form.AddField("Tag_FlashingColors", 1);
|
||||
if (updater.FlashingLights.isOn) form.AddField("Tag_FlashingLights", 1);
|
||||
if (updater.ExtremelyBright.isOn) form.AddField("Tag_ExtremelyBright", 1);
|
||||
if (updater.ScreenEffects.isOn) form.AddField("Tag_ScreenEffects", 1);
|
||||
if (updater.ParticleSystems.isOn) form.AddField("Tag_ParticleSystems", 1);
|
||||
|
||||
if (updater.Violence.isOn) form.AddField("Tag_Violence", 1);
|
||||
if (updater.Gore.isOn) form.AddField("Tag_Gore", 1);
|
||||
if (updater.Horror.isOn) form.AddField("Tag_Horror", 1);
|
||||
if (updater.Jumpscare.isOn) form.AddField("Tag_Jumpscare", 1);
|
||||
|
||||
if (updater.ExcessivelyHuge.isOn) form.AddField("Tag_ExcessivelyHuge", 1);
|
||||
if (updater.ExcessivelySmall.isOn) form.AddField("Tag_ExcessivelySmall", 1);
|
||||
|
||||
if (updater.Suggestive.isOn) form.AddField("Tag_Suggestive", 1);
|
||||
if (updater.Nudity.isOn) form.AddField("Tag_Nudity", 1);
|
||||
|
||||
if (updater.SetAsActive.isOn) form.AddField("Flag_SetFileAsActive", 1);
|
||||
if (overwritePic) form.AddField("Flag_OverwritePicture", 1);
|
||||
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
string fieldName = string.Empty;
|
||||
switch (i)
|
||||
{
|
||||
case 0: fieldName = "AssetFile"; break;
|
||||
case 1: fieldName = "AssetManifestFile"; break;
|
||||
case 2: fieldName = "AssetThumbnail"; break;
|
||||
case 3: fieldName = "AssetPano1K"; break;
|
||||
case 4: fieldName = "AssetPano4K"; break;
|
||||
}
|
||||
files[i] = UnityWebRequest.Get(path[i]);
|
||||
yield return files[i].SendWebRequest();
|
||||
form.AddBinaryData(fieldName, files[i].downloadHandler.data, Path.GetFileName(path[i]));
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
req = UnityWebRequest.Post($"https://{updater.UploadLocation}/v1/upload-file", form);
|
||||
#endif
|
||||
isUploading = true;
|
||||
yield return req.SendWebRequest();
|
||||
|
||||
if (req.isHttpError || req.isNetworkError)
|
||||
Debug.LogError(req.error);
|
||||
}
|
||||
|
||||
private IEnumerator WriteState()
|
||||
{
|
||||
_stateTransfer = true;
|
||||
yield return new WaitForSeconds(0.15f);
|
||||
float percent = 0f;
|
||||
while (99f > percent)
|
||||
{
|
||||
var values = new Dictionary<string, string>
|
||||
{
|
||||
{"ContentType", updater.asset.type.ToString()},
|
||||
{"ContentId", updater.asset.objectId}
|
||||
};
|
||||
|
||||
using (UnityWebRequest uwr =
|
||||
UnityWebRequest.Post($"https://{updater.UploadLocation}/v1/progress-for-file", values))
|
||||
{
|
||||
yield return uwr.SendWebRequest();
|
||||
|
||||
if (uwr.isNetworkError || uwr.isHttpError)
|
||||
{
|
||||
Debug.Log(
|
||||
"[CCK:RuntimeUploader] Unable to connect to the edge we are uploading to. There might be a network issue.");
|
||||
yield break;
|
||||
}
|
||||
|
||||
UploadProgressStatus s =
|
||||
JsonConvert.DeserializeObject<UploadProgressStatus>(uwr.downloadHandler.text);
|
||||
if (s != null)
|
||||
{
|
||||
updater.processingProgress.fillAmount = s.Percent / 100;
|
||||
if (!string.IsNullOrEmpty(s.CurrentStep)) updater.processingProgressText.text = CCKLocalizationProvider.GetLocalizedText(s.CurrentStep);
|
||||
if (s.Percent > 99f) ShowResponseDialog(s.CurrentStep);
|
||||
percent = s.Percent;
|
||||
}
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (isUploading)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
updater.uploadProgress.fillAmount = req.uploadProgress;
|
||||
updater.uploadProgressText.text = (req.uploadProgress * 100f).ToString("F2") + "%";
|
||||
if (req.uploadProgress * 100f > 99.9f)
|
||||
{
|
||||
updater.uploadProgressText.text = "100%";
|
||||
if (!_stateTransfer) StartCoroutine(WriteState());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowResponseDialog(string text)
|
||||
{
|
||||
isUploading = false;
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.ClearProgressBar();
|
||||
if (UnityEditor.EditorUtility.DisplayDialog("Alpha Blend Interactive CCK",$"Message from server: {CCKLocalizationProvider.GetLocalizedText(text)}","Okay"))
|
||||
{
|
||||
EditorApplication.isPlaying = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class UploadProgressStatus
|
||||
{
|
||||
public string CurrentStep { get; set; }
|
||||
public float Percent { get; set; }
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeUploaderMaster.cs.meta
Executable file
11
Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeUploaderMaster.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6256163c59631774c9883799367a37fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
182
Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeVariableStream.cs
Executable file
182
Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeVariableStream.cs
Executable file
|
@ -0,0 +1,182 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Abi.Newtonsoft.Json;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Scripts.Runtime
|
||||
{
|
||||
public class CCK_RuntimeVariableStream : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(StreamVars());
|
||||
}
|
||||
|
||||
private IEnumerator StreamVars()
|
||||
{
|
||||
OnGuiUpdater updater = gameObject.GetComponent<OnGuiUpdater>();
|
||||
string type = updater.asset.type.ToString();
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
string result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
BaseResponse<VariableStreamResponse> streamResponse = Abi.Newtonsoft.Json.JsonConvert .DeserializeObject<BaseResponse<VariableStreamResponse>>(result);
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeVariableStream.cs.meta
Executable file
3
Assets/ABI.CCK/Scripts/Runtime/CCK_RuntimeVariableStream.cs.meta
Executable file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 43627592c5424481910b2e2c00ff9078
|
||||
timeCreated: 1574699299
|
19
Assets/ABI.CCK/Scripts/Runtime/CCK_TexImageCreation.cs
Executable file
19
Assets/ABI.CCK/Scripts/Runtime/CCK_TexImageCreation.cs
Executable file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CCK_TexImageCreation : MonoBehaviour
|
||||
{
|
||||
public void SaveTexture (Camera cam, RenderTexture renderTexture,int resWidth = 512, int resHeight = 512) {
|
||||
Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
|
||||
cam.Render();
|
||||
RenderTexture.active = renderTexture;
|
||||
screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
|
||||
screenShot.Apply();
|
||||
cam.targetTexture = null;
|
||||
RenderTexture.active = null;
|
||||
byte[] bytes = screenShot.EncodeToPNG();
|
||||
System.IO.File.WriteAllBytes(Application.persistentDataPath + "/bundle.png", bytes);
|
||||
}
|
||||
|
||||
}
|
11
Assets/ABI.CCK/Scripts/Runtime/CCK_TexImageCreation.cs.meta
Executable file
11
Assets/ABI.CCK/Scripts/Runtime/CCK_TexImageCreation.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f49ae1874bfcdb74583d0f7bd5b123e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
Assets/ABI.CCK/Scripts/Runtime/LinkOpener.cs
Executable file
12
Assets/ABI.CCK/Scripts/Runtime/LinkOpener.cs
Executable file
|
@ -0,0 +1,12 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Scripts.Runtime
|
||||
{
|
||||
public class LinkOpener : MonoBehaviour
|
||||
{
|
||||
public void OpenLink(string url)
|
||||
{
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Scripts/Runtime/LinkOpener.cs.meta
Executable file
11
Assets/ABI.CCK/Scripts/Runtime/LinkOpener.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 795f0798827ab3449b33533e117fb343
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
267
Assets/ABI.CCK/Scripts/Runtime/OnGuiUpdater.cs
Executable file
267
Assets/ABI.CCK/Scripts/Runtime/OnGuiUpdater.cs
Executable file
|
@ -0,0 +1,267 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using ABI.CCK.Components;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ABI.CCK.Scripts.Runtime
|
||||
{
|
||||
public class OnGuiUpdater : MonoBehaviour
|
||||
{
|
||||
[Space] [Header("Object details")] [Space]
|
||||
public Text uiTitle;
|
||||
public InputField assetName;
|
||||
public InputField assetDesc;
|
||||
public InputField assetChangelog;
|
||||
|
||||
[Space] [Header("Object tags")] [Space]
|
||||
public Toggle LoudAudio;
|
||||
public Toggle LongRangeAudio;
|
||||
public Toggle SpawnAudio;
|
||||
public Toggle ContainsMusic;
|
||||
public Toggle ScreenEffects;
|
||||
public Toggle FlashingColors;
|
||||
public Toggle FlashingLights;
|
||||
public Toggle ExtremelyBright;
|
||||
public Toggle ParticleSystems;
|
||||
public Toggle Violence;
|
||||
public Toggle Gore;
|
||||
public Toggle Horror;
|
||||
public Toggle Jumpscare;
|
||||
public Toggle ExcessivelyHuge;
|
||||
public Toggle ExcessivelySmall;
|
||||
public Toggle Suggestive;
|
||||
public Toggle Nudity;
|
||||
|
||||
public Toggle dontOverridePicture;
|
||||
public Toggle SetAsActive;
|
||||
|
||||
//Regulatory
|
||||
public Toggle contentOwnership;
|
||||
public Toggle tagsCorrect;
|
||||
|
||||
[Space] [Header("Object reference")] [Space]
|
||||
public CVRAssetInfo asset;
|
||||
|
||||
[Space] [Header("UIHelper objects")] [Space]
|
||||
public GameObject camObj;
|
||||
public RenderTexture tex;
|
||||
public RawImage texView;
|
||||
public RawImage texViewBig;
|
||||
public GameObject tagsObject;
|
||||
public GameObject detailsObject;
|
||||
public GameObject legalObject;
|
||||
public GameObject uploadObject;
|
||||
public Image stepOne;
|
||||
public Image stepTwo;
|
||||
public Image stepThree;
|
||||
public Image tagsImage;
|
||||
public Image detailsImage;
|
||||
public Image legalImage;
|
||||
public Image uploadImage;
|
||||
public Text tagsText;
|
||||
public Text detailsText;
|
||||
public Text legalText;
|
||||
public Text uploadText;
|
||||
public Image uploadProgress;
|
||||
public Text uploadProgressText;
|
||||
public Image processingProgress;
|
||||
public Text processingProgressText;
|
||||
public Text assetFileSizeText;
|
||||
public Text assetImageFileSizeText;
|
||||
public Text assetFileManifestSizeText;
|
||||
public Text assetFilePano1SizeText;
|
||||
public Text assetFilePano4SizeText;
|
||||
|
||||
[HideInInspector] public string UploadLocation;
|
||||
|
||||
public CCK_RuntimeUploaderMaster uploader;
|
||||
|
||||
public void ToggleObject(GameObject obj)
|
||||
{
|
||||
obj.SetActive(!obj.activeInHierarchy);
|
||||
}
|
||||
|
||||
public static string ToFileSizeString(long fileSize)
|
||||
{
|
||||
string[] sizes = { "B", "KB", "MB", "GB", "TB" };
|
||||
int order = 0;
|
||||
while (fileSize >= 1024 && order < sizes.Length - 1) {
|
||||
order++;
|
||||
fileSize = fileSize/1024;
|
||||
}
|
||||
|
||||
return $"{fileSize:0.##} {sizes[order]}";
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
SwitchPage(0);
|
||||
CVRAssetInfo.AssetType type = asset.GetComponent<CVRAssetInfo>().type;
|
||||
|
||||
if (type == CVRAssetInfo.AssetType.World)
|
||||
{
|
||||
Scripts.Editor.CCK_WorldPreviewCapture.CreatePanoImages();
|
||||
}
|
||||
|
||||
tex = new RenderTexture(512,512,1, RenderTextureFormat.ARGB32);
|
||||
tex.Create();
|
||||
|
||||
camObj = new GameObject();
|
||||
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);
|
||||
var cam = camObj.AddComponent<Camera>();
|
||||
cam.aspect = 1f;
|
||||
cam.nearClipPlane = 0.01f;
|
||||
cam.targetTexture = tex;
|
||||
texView.texture = tex;
|
||||
texViewBig.texture = tex;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#endif
|
||||
|
||||
if (type == CVRAssetInfo.AssetType.Avatar)
|
||||
{
|
||||
assetFileSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.cvravatar").Length);
|
||||
assetImageFileSizeText.text = "N/A";
|
||||
assetFileManifestSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.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);
|
||||
assetImageFileSizeText.text = "";
|
||||
assetFileManifestSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.cvrprop.manifest").Length);
|
||||
assetFilePano1SizeText.text = "N/A";
|
||||
assetFilePano4SizeText.text = "N/A";
|
||||
}
|
||||
|
||||
if (type == CVRAssetInfo.AssetType.World)
|
||||
{
|
||||
assetFileSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.cvrworld").Length);
|
||||
assetImageFileSizeText.text = "N/A";
|
||||
assetFileManifestSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.cvrworld.manifest").Length);
|
||||
assetFilePano1SizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle_pano_1024.png").Length);
|
||||
assetFilePano4SizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle_pano_4096.png").Length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SwitchPage(int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
tagsObject.SetActive(true);
|
||||
detailsObject.SetActive(false);
|
||||
legalObject.SetActive(false);
|
||||
uploadObject.SetActive(false);
|
||||
stepOne.color = Color.white;
|
||||
stepTwo.color = Color.white;
|
||||
stepThree.color = Color.white;
|
||||
tagsImage.color = Color.yellow;
|
||||
detailsImage.color = Color.white;
|
||||
legalImage.color = Color.white;
|
||||
uploadImage.color = Color.white;
|
||||
tagsText.color = Color.yellow;
|
||||
detailsText.color = Color.white;
|
||||
legalText.color = Color.white;
|
||||
uploadText.color = Color.white;
|
||||
break;
|
||||
case 1:
|
||||
tagsObject.SetActive(false);
|
||||
detailsObject.SetActive(true);
|
||||
legalObject.SetActive(false);
|
||||
uploadObject.SetActive(false);
|
||||
stepOne.color = Color.green;
|
||||
stepTwo.color = Color.white;
|
||||
stepThree.color = Color.white;
|
||||
tagsImage.color = Color.green;
|
||||
detailsImage.color = Color.yellow;
|
||||
legalImage.color = Color.white;
|
||||
uploadImage.color = Color.white;
|
||||
tagsText.color = Color.green;
|
||||
detailsText.color = Color.yellow;
|
||||
legalText.color = Color.white;
|
||||
uploadText.color = Color.white;
|
||||
break;
|
||||
case 2:
|
||||
tagsObject.SetActive(false);
|
||||
detailsObject.SetActive(false);
|
||||
legalObject.SetActive(true);
|
||||
uploadObject.SetActive(false);
|
||||
stepOne.color = Color.green;
|
||||
stepTwo.color = Color.green;
|
||||
stepThree.color = Color.white;
|
||||
tagsImage.color = Color.green;
|
||||
detailsImage.color = Color.green;
|
||||
legalImage.color = Color.yellow;
|
||||
uploadImage.color = Color.white;
|
||||
tagsText.color = Color.green;
|
||||
detailsText.color = Color.green;
|
||||
legalText.color = Color.yellow;
|
||||
uploadText.color = Color.white;
|
||||
break;
|
||||
case 3:
|
||||
tagsObject.SetActive(false);
|
||||
detailsObject.SetActive(false);
|
||||
legalObject.SetActive(false);
|
||||
uploadObject.SetActive(true);
|
||||
stepOne.color = Color.green;
|
||||
stepTwo.color = Color.green;
|
||||
stepThree.color = Color.green;
|
||||
tagsImage.color = Color.green;
|
||||
detailsImage.color = Color.green;
|
||||
legalImage.color = Color.green;
|
||||
uploadImage.color = Color.yellow;
|
||||
tagsText.color = Color.green;
|
||||
detailsText.color = Color.green;
|
||||
legalText.color = Color.green;
|
||||
uploadText.color = Color.yellow;
|
||||
if (string.IsNullOrEmpty(assetName.text))
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDSTEP_UPLOAD_DETAILS_MISSING"), "Okay");
|
||||
#endif
|
||||
SwitchPage(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!contentOwnership.isOn || !tagsCorrect.isOn)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.DisplayDialog("Alpha Blend Interactive CCK", CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDSTEP_UPLOAD_LEGAL_MISSING"), "Okay");
|
||||
#endif
|
||||
SwitchPage(2);
|
||||
return;
|
||||
}
|
||||
uploader.StartUpload();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void MakePhotoAndDisableCamera()
|
||||
{
|
||||
|
||||
Camera c = camObj.GetComponent<Camera>();
|
||||
if (!c.enabled)
|
||||
{
|
||||
c.targetTexture = tex;
|
||||
c.enabled = true;
|
||||
}
|
||||
gameObject.GetComponent<CCK_TexImageCreation>().SaveTexture(c, tex);
|
||||
assetImageFileSizeText.text = ToFileSizeString(new FileInfo(Application.persistentDataPath + "/bundle.png").Length);
|
||||
c.enabled = false;
|
||||
//
|
||||
//StartCoroutine(MakePhotoAndDisableCamera__Internal());
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Scripts/Runtime/OnGuiUpdater.cs.meta
Executable file
11
Assets/ABI.CCK/Scripts/Runtime/OnGuiUpdater.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2412f7e29bae9b64fbf2558565dad1ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue