[03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC]

1. Modified Portrait feature.
2. Removed useless feature.
master
LH 6 years ago
parent b9be571eac
commit bb42eae43d
  1. 2258
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait.unity
  2. 29
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Script/Portrait.cs
  3. 46
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Script/PortraitController.cs
  4. 2
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Script/PortraitController.cs.meta
  5. 28
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Script/PortraitManager.cs
  6. 141
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Script/ResourceServer.cs
  7. 36
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Script/RorayGalleryGrpcServer.cs
  8. 4
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Texture/RT-Filter.renderTexture
  9. 8
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Texture/RT-Filter.renderTexture.meta
  10. 34
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Texture/RT-PortraitManager.renderTexture
  11. 2
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Assets/RoyalGalleryPortrait/Texture/RT-PortraitManager.renderTexture.meta
  12. 10
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/Logs/Packages-Update.log
  13. 11
      03_RoyalGallery/Unity-19050-03_RoyalGallery_Portrait_PC/19050-03_RoyalGallery_Portrait_PC/ProjectSettings/VFXManager.asset

@ -9,10 +9,14 @@ namespace UltraCombos.Frozen
public class Portrait : MonoBehaviour
{
public string id;
public Color32 BackgroundColor;
public Vector2 Positon;
const float duration = 150.0f;
float stamp = 0.0f;
RendererPropertyOverride prop;
//RendererPropertyOverride prop;
RawImage image;
Texture2D tex;
Texture blank_texture;
@ -20,19 +24,6 @@ namespace UltraCombos.Frozen
Animator animator = null;
float speed = 0.0f;
public bool isVisible
{
set
{
prop.isVisible = value;
}
get
{
return prop.isVisible;
}
}
[SerializeField, Header("Debug")]
bool mode = false;
@ -55,14 +46,16 @@ namespace UltraCombos.Frozen
private void Start()
{
prop = GetComponent<RendererPropertyOverride>();
blank_texture = GetComponent<SpriteRenderer>().sprite.texture;
image = GetComponent<RawImage>();
blank_texture = image.texture;
/*
animator = GetComponent<Animator>();
if (animator)
{
animator.speed = 0.0f;
}
*/
}
private void Update()
@ -112,7 +105,7 @@ namespace UltraCombos.Frozen
tex.SetPixels(texture.GetPixels());
tex.Apply();
prop.texture = tex;
image.texture = tex;
}
private void OnTrigger()
@ -123,7 +116,7 @@ namespace UltraCombos.Frozen
public void Initialize()
{
prop.texture = blank_texture;
image.texture = blank_texture;
speed = 0.0f;
}
}

@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
namespace UltraCombos.Frozen
{
[ExecuteInEditMode]
public class PortraitController : MonoBehaviour
{
// Start is called before the first frame update
RawImage background;
Portrait portrait;
RectTransform rt;
void Start()
{
portrait = GetComponentInChildren<Portrait>();
background = GetComponent<RawImage>();
rt = GetComponent<RectTransform>();
background.color = portrait.BackgroundColor;
portrait.Positon = rt.anchoredPosition;
}
// Update is called once per frame
void Update()
{
if (Application.isPlaying)
{
return;
}
if (portrait)
{
background.color = portrait.BackgroundColor;
}
if (rt)
{
portrait.Positon = rt.anchoredPosition;
}
}
}
}

@ -10,6 +10,8 @@ namespace UltraCombos.Frozen
{
Dictionary<string, Portrait> portraits;
public string show_cur;
public Camera camera;
public RoyalGallery.RorayGalleryGrpcServer server;
string show_nxt = null;
@ -28,7 +30,7 @@ namespace UltraCombos.Frozen
foreach (var p in GetComponentsInChildren<Portrait>())
{
portraits.Add(p.id, p);
p.isVisible = false;
// p.isVisible = false;
}
if (portraits.Count == 0)
@ -45,6 +47,11 @@ namespace UltraCombos.Frozen
{
show_nxt = show_cur;
}
if (server)
{
server.onRequestColor = RequestColor;
}
}
private void Update()
@ -58,12 +65,17 @@ namespace UltraCombos.Frozen
{
if (portraits.ContainsKey(show_cur))
{
portraits[show_cur].isVisible = false;
//portraits[show_cur].isVisible = false;
}
show_cur = show_nxt;
show_nxt = null;
portraits[show_cur].isVisible = true;
Transform tf = camera.GetComponent<Transform>();
Vector2 tar = portraits[show_cur].Positon;
camera.GetComponent<Transform>().localPosition = new Vector3(tar.x, tar.y, tf.localPosition.z);
//portraits[show_cur].isVisible = true;
}
if (Input.GetKeyDown(KeyCode.R))
@ -93,6 +105,16 @@ namespace UltraCombos.Frozen
show_nxt = id;
}
}
private Color32 RequestColor(string id)
{
if (portraits.ContainsKey(id))
{
return portraits[id].BackgroundColor;
}
return new Color32(255, 255, 255, 255);
}
}
}

@ -1,141 +0,0 @@
using Grpc.Core;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
namespace UltraCombos.Minions
{
public class ResourceServer : GrpcServerBase
{
public string subnet = "192.168.234.0";
public Texture2D texture;
object data_mtx = new object();
Queue<DataRequest> data_pool;
object idx_mtx = new object();
public int maxCount = 10;
public int index = 0;
[System.Serializable]
public class TextureEvent : UnityEvent<int, Texture2D> { }
[Space(10)]
public TextureEvent onTextureReceived = new TextureEvent();
public delegate void MessageDelegate(DataRequest request);
public MessageDelegate onMessageReceived;
private void Start()
{
Utility.Argument.TryParse("subnet", ref subnet);
data_pool = new Queue<DataRequest>();
var options = new List<Grpc.Core.ChannelOption> { new Grpc.Core.ChannelOption(ChannelOptions.MaxReceiveMessageLength, int.MaxValue) };
var services = new ServerServiceDefinition[] { Resource.BindService(new ResourceImpl(OnMessageReceived, OnIndexRequest)) };
StartServer(options, services);
DebugInformation.Instance.UpdateProperty("Local IP", $"{Utility.Network.GetLocalIPAddress(subnet)}");
}
private void Update()
{
DataRequest data = null;
lock (data_mtx)
{
if (data_pool.Count > 0)
{
data = data_pool.Dequeue();
}
}
if (data != null)
{
int role_id = data.Id;
if (texture == null)
{
texture = new Texture2D(1024, 1024, TextureFormat.ARGB32, false);
}
if (texture.LoadImage(data.Content.ToByteArray(), false))
{
onMessageReceived.Invoke(data);
onTextureReceived.Invoke(role_id, texture);
Log($"Texture {role_id} is loaded. ({texture.width} x {texture.height})");
DebugInformation.Instance.UpdateProperty("Last painting", $"{role_id} ({texture.width} x {texture.height})");
}
else
{
Log("Texture load fail.", LogType.Error);
DebugInformation.Instance.UpdateProperty("Last painting", $"load fail");
}
}
DebugInformation.Instance.UpdateProperty("Resouce Server", $"{port}");
}
private void OnMessageReceived(DataRequest request)
{
//Log($"Request content length: {request.Content.Length}");
lock (data_mtx)
{
data_pool.Enqueue(request);
}
}
private int OnIndexRequest(int deviceId)
{
int res = 0;
lock (idx_mtx)
{
res = index;
index = (index + 1) % maxCount;
}
return res;
}
}
internal class ResourceImpl : Resource.ResourceBase
{
public delegate void MessageDelegate(DataRequest request);
public MessageDelegate onMessageReceived;
public delegate int IndexDelegate(int deviceId);
public IndexDelegate onIndexRequest;
public ResourceImpl(MessageDelegate msg_func, IndexDelegate index_func)
{
if (msg_func != null)
onMessageReceived += msg_func;
if (index_func != null)
onIndexRequest += index_func;
}
public override Task<DataReply> SendData(DataRequest request, ServerCallContext context)
{
onMessageReceived.Invoke(request);
return Task.FromResult(new DataReply { Result = $"Texture {request.Id} data is delivered with length: {request.Content.Length}." });
}
public override Task<Index> GetIndex(Index request, ServerCallContext context)
{
var res = onIndexRequest.Invoke(request.Id);
string serial = $"{System.DateTime.Now.ToString("HHmmss")}{res:D2}";
return Task.FromResult(new Index { Id = res, Serial = serial });
}
}
}

@ -8,6 +8,12 @@ using UnityEngine.Networking;
namespace UltraCombos.Frozen.RoyalGallery
{
class IndexInfo
{
public string id;
public Color32 color;
}
public class RorayGalleryGrpcServer : GrpcServerBase
{
public string subnet = "192.168.234.0";
@ -27,6 +33,9 @@ namespace UltraCombos.Frozen.RoyalGallery
[Space(10)]
public TextureEvent onTextureReceived = new TextureEvent();
public delegate Color32 RequestColorDelegate(string id);
public RequestColorDelegate onRequestColor;
public delegate void MessageDelegate(DataRequest request);
public MessageDelegate onMessageReceived;
@ -107,7 +116,7 @@ namespace UltraCombos.Frozen.RoyalGallery
}
}
private string OnIndexRequest(int deviceId)
private IndexInfo OnIndexRequest(int deviceId)
{
int res = 0;
lock (idx_mtx)
@ -115,16 +124,22 @@ namespace UltraCombos.Frozen.RoyalGallery
res = index;
index = (index + 1) % m_IdList.Count;
}
return m_IdList[index];
IndexInfo info = new IndexInfo();
info.id = m_IdList[index];
info.color = onRequestColor(info.id);
return info;
}
}
internal class ResourceImpl : Resource.ResourceBase
{
public delegate void MessageDelegate(DataRequest request);
public MessageDelegate onMessageReceived;
public delegate string IndexDelegate(int deviceId);
public delegate IndexInfo IndexDelegate(int deviceId);
public IndexDelegate onIndexRequest;
public ResourceImpl(MessageDelegate msg_func, IndexDelegate index_func)
@ -147,22 +162,23 @@ namespace UltraCombos.Frozen.RoyalGallery
var res = onIndexRequest.Invoke(request.Id);
string dev_id = request.Id.ToString("X");//request.Id.ToString().PadLeft(2, '0');
string dev_sid = request.Id.ToString("X");
string date = System.DateTime.Now.ToString("HHmmss");
string res_id = res;//res.PadLeft(3, '0');
string res_sid = res.id;
try
{
res_id = System.Int32.Parse(res_id).ToString("X");
res_sid = System.Int32.Parse(res_sid).ToString("X");
}
catch (System.FormatException)
{
Debug.LogWarning($"GetPage: rid={res} is not number.");
Debug.LogWarning($"GetPage: rid={res_sid} is not number.");
}
string serial = $"{date}{dev_id}{res_id}";
string serial = $"{date}{dev_sid}{res_sid}";
string colorHex = Utils.ColorToHex(res.color);
Debug.Log($"GetPage: rid={res}, sid={serial}");
return Task.FromResult(new Page { Id = res, Serial = serial });
Debug.Log($"GetPage: rid={res.id}, sid={serial}, color={colorHex}");
return Task.FromResult(new Page { Id = res.id, Serial = serial, Message = colorHex });
}
}
}

@ -6,7 +6,7 @@ RenderTexture:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: wall
m_Name: RT-Filter
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
@ -14,7 +14,7 @@ RenderTexture:
m_DownscaleFallback: 0
m_Width: 1080
m_Height: 1920
m_AntiAliasing: 4
m_AntiAliasing: 1
m_DepthFormat: 0
m_ColorFormat: 0
m_MipMap: 0

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ec4cfe790f7e53e40930b3f3b1d0ea7b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,34 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!84 &8400000
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: RT-PortraitManager
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_Width: 1080
m_Height: 1920
m_AntiAliasing: 1
m_DepthFormat: 0
m_ColorFormat: 0
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1

@ -0,0 +1,10 @@
=== Sun Dec 1 01:08:41 2019
Packages were changed.
Update Mode: updateDependencies
The following packages were added:
com.unity.collab-proxy@1.2.15
The following packages were updated:
com.unity.package-manager-ui from version 1.9.11 to 2.0.8

@ -0,0 +1,11 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!937362698 &1
VFXManager:
m_ObjectHideFlags: 0
m_IndirectShader: {fileID: 0}
m_CopyBufferShader: {fileID: 0}
m_SortShader: {fileID: 0}
m_RenderPipeSettingsPath:
m_FixedTimeStep: 0.016666668
m_MaxDeltaTime: 0.05
Loading…
Cancel
Save