123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- using ShadowStudio.Model;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- using Newtonsoft.Json;
- using ShadowStudio.UI;
- using SC.XR.Unity.Module_InputSystem;
- using ShadowStudio.Tool;
- using XRTool.UI;
- public class TestArtCreate : MonoBehaviour
- {
- public ArtType artType;
- public int indexOfArt;
- public Transform left;
- public Transform right;
- public PlayerAnimatorController PlayerAnimator;
- public Renderer TestRender;
- // Start is called before the first frame update
- void Start()
- {
- ArtInfoMgr.Instance.OpenLocalData();
- //TransferState state = (TransferState)10;
- //print(state.ToString());
- //PlayerAnimator.SetHands(left,right);
- //DispatcherBase.KeyDownDelegateRegister(OnKeyDownAction);
- //DispatcherBase.KeyUpDelegateRegister(OnKeyUpAction);
- //if (DataConfMgr<ServerConfig>.Instance.TableHelper == null)
- //{
- // DataConfMgr<ServerConfig>.Instance.OpenData(Application.persistentDataPath);
- //}
- //DataConfMgr<ServerConfig>.Instance.TableHelper.readConfComplete += OnReadConfComplete;
- //DataConfMgr<ServerConfig>.Instance.OpenTable("serverName");
- }
- private void OnReadConfComplete()
- {
- if (DataConfMgr<ServerConfig>.Instance.TableHelper.DataList != null && DataConfMgr<ServerConfig>.Instance.TableHelper.DataList.Count > 0)
- {
- print(JsonConvert.SerializeObject( DataConfMgr<ServerConfig>.Instance.TableHelper.DataList));
- }
- else
- {
- ServerConfig sc = new ServerConfig();
- sc.serverName = "fat";
- sc.loginUrl = "https://webapi-fat.shadowcreator.com/100009/index.php?s=index/command/gateway";
- sc.lobbyUrl = "wss://studiosignaling.tech.shadowcreator.com/fatlobby/?appId=100009";
- sc.roomUrl = "wss://studiosignaling.tech.shadowcreator.com/fatroom/?token=";
- sc.rtcUrl = "wss://studiosignaling.tech.shadowcreator.com/rtc/";
- DataConfMgr<ServerConfig>.Instance.TableHelper.AddData(sc);
- }
- }
- private void OnKeyUpAction(InputKeyCode keyCode, InputDevicePartBase part)
- {
- if (part.PartType == InputDevicePartType.HandLeft)
- {
- if (PlayerAnimator)
- {
- PlayerAnimator.LeftHandState = 0;
- }
- }
- else if (part.PartType == InputDevicePartType.HandRight)
- {
- if (PlayerAnimator)
- {
- PlayerAnimator.RightHandState = 0;
- }
- }
- }
- private void OnKeyDownAction(InputKeyCode keyCode, InputDevicePartBase part)
- {
- if (part.PartType == InputDevicePartType.HandLeft)
- {
- if (PlayerAnimator)
- {
- PlayerAnimator.LeftHandState = 1;
- }
- }
- else if (part.PartType == InputDevicePartType.HandRight)
- {
- if (PlayerAnimator)
- {
- PlayerAnimator.RightHandState = 1;
- }
- }
- }
- private void GetAllInfo()
- {
- for (int i = 0; i < ArtInfoMgr.Instance.ArtInfoList.Count; i++)
- {
- print(ArtInfoMgr.Instance.ArtInfoList[i].ArtName);
- }
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Space))
- {
- CreateUser();
- }
- if (Input.GetKeyDown(KeyCode.C))
- {
- CreateArt(artType, indexOfArt);
- }
- if (Input.GetKeyDown(KeyCode.F))
- {
- for (int i = 0; i < ArtInfoMgr.Instance.ArtInfoList.Count; i++)
- {
- CreateArt(ArtInfoMgr.Instance.ArtInfoList[i]);
- }
- }
- PlayerAnimator.transform.position = GameSession.Instance.gameHead.position;
- PlayerAnimator.transform.forward = GameSession.Instance.BodyForward;
- PlayerAnimator.playerHead.rotation = GameSession.Instance.gameHead.rotation;
- Vector3 leftpos;
- Quaternion leftRot;
- if (GameSession.Instance.TryHandLeftPosition(out leftpos, out leftRot))
- {
- if (!PlayerAnimator.HandLeft.gameObject.activeSelf)
- {
- PlayerAnimator.HandLeft.gameObject.SetActive(true);
- }
- PlayerAnimator.HandLeft.position = leftpos;
- PlayerAnimator.HandLeft.rotation = leftRot;
- }
- else
- {
- if (PlayerAnimator.HandLeft.gameObject.activeSelf)
- {
- PlayerAnimator.HandLeft.gameObject.SetActive(false);
- }
- }
- Vector3 rightpos;
- Quaternion rightRot;
- if (GameSession.Instance.TryHandRightPosition(out rightpos, out rightRot))
- {
- if (!PlayerAnimator.HandRight.gameObject.activeSelf)
- {
- PlayerAnimator.HandRight.gameObject.SetActive(true);
- }
- PlayerAnimator.HandRight.position = rightpos;
- PlayerAnimator.HandRight.rotation = rightRot;
- }
- else
- {
- if (PlayerAnimator.HandRight.gameObject.activeSelf)
- PlayerAnimator.HandRight.gameObject.SetActive(false);
- }
- }
- /// <summary>
- /// 创建用户
- /// </summary>
- public void CreateUser()
- {
- CommonMethod.MyPeer = new Peer();
- CommonMethod.MyPeer.PeerId = "Test";
- CommonMethod.MyPeer.NickName = "Test";
- ArtInfoMgr.Instance.OnUserChange(new List<Peer>() { CommonMethod.MyPeer }, true);
- }
- private void CreateArt(ArtInfo info)
- {
- ArtHandler handler = ArtInfoMgr.Instance.CreateArtHandler(info);
- handler.CreateArt();
- }
- private void CreateArt(ArtType artType, int indexOfArt)
- {
- Debug.Log(artType);
- var list = ArtInfoMgr.Instance.GetArtInfoList(artType);
- if (list != null)
- {
- print(list.Count);
- if (indexOfArt >= 0 && indexOfArt < list.Count)
- {
- ArtInfo info = list[indexOfArt];
- print(info.ArtName);
- ArtHandler handler = ArtInfoMgr.Instance.CreateArtHandler(info);
- print(handler.GetIcon());
- var container = handler.CreateArt();
- container.Position = GameSession.Instance.GetHeadForwadPos(1);
- //gameObject.hideFlags = HideFlags.HideAndDontSave;
- }
- }
- else
- {
- UnityLog.Instance.LogError(artType.ToString() + " is null list!");
- }
- }
- }
|