FIX : 소소한 버그 패치

This commit is contained in:
DESKTOP-S4BOTN2\user 2025-05-03 17:53:42 +09:00
parent e9e1c12284
commit 295645f0da
9 changed files with 83 additions and 132 deletions

View File

@ -16,22 +16,15 @@ public class UnityRecieve_FACEMOTION3D_and_iFacialMocap : MonoBehaviour
private UdpClient client;
private bool StartFlag = true;
//object names
public string faceObjectGroupName = "";
public string headBoneName = "";
public string rightEyeBoneName = "";
public string leftEyeBoneName = "";
public string headPositionObjectName = "";
//object references
public SkinnedMeshRenderer[] faceMeshRenderers;
public Transform headBone;
public Transform rightEyeBone;
public Transform leftEyeBone;
public Transform headPositionObject;
private UdpClient udp;
private Thread thread;
private SkinnedMeshRenderer meshTarget;
private List<SkinnedMeshRenderer> meshTargetList;
private List<GameObject> headObjectArray;
private List<GameObject> rightEyeObjectArray;
private List<GameObject> leftEyeObjectArray;
private List<GameObject> headPositionObjectArray;
private string messageString = "";
public int LOCAL_PORT = 49983;
@ -62,11 +55,18 @@ public class UnityRecieve_FACEMOTION3D_and_iFacialMocap : MonoBehaviour
void CreateUdpServer()
{
udp = new UdpClient(LOCAL_PORT);
udp.Client.ReceiveTimeout = 5;
try
{
udp = new UdpClient(LOCAL_PORT);
udp.Client.ReceiveTimeout = 5;
thread = new Thread(new ThreadStart(ThreadMethod));
thread.Start();
thread = new Thread(new ThreadStart(ThreadMethod));
thread.Start();
}
catch (Exception e)
{
Debug.LogError($"[iFacialMocap] UDP 서버 생성 실패: {e.Message}");
}
}
IEnumerator WaitProcess(float WaitTime)
@ -76,11 +76,18 @@ public class UnityRecieve_FACEMOTION3D_and_iFacialMocap : MonoBehaviour
void Connect_to_iOS_App()
{
//iFacialMocap
SendMessage_to_iOSapp("iFacialMocap_sahuasouryya9218sauhuiayeta91555dy3719", 49983);
try
{
//iFacialMocap
SendMessage_to_iOSapp("iFacialMocap_sahuasouryya9218sauhuiayeta91555dy3719", 49983);
//Facemotion3d
SendMessage_to_iOSapp("FACEMOTION3D_OtherStreaming", 49993);
//Facemotion3d
SendMessage_to_iOSapp("FACEMOTION3D_OtherStreaming", 49993);
}
catch (Exception e)
{
Debug.LogError($"[iFacialMocap] iOS 앱 연결 실패: {e.Message}");
}
}
void StopStreaming_iOS_App()
@ -90,20 +97,24 @@ public class UnityRecieve_FACEMOTION3D_and_iFacialMocap : MonoBehaviour
//iOSアプリに通信開始のメッセージを送信
//Send a message to the iOS application to start streaming
void SendMessage_to_iOSapp(string sendMessage,int send_port)
void SendMessage_to_iOSapp(string sendMessage, int send_port)
{
try
{
client = new UdpClient();
client.Connect(iOS_IPAddress, send_port);
byte[] dgram = Encoding.UTF8.GetBytes(sendMessage);
client.Send(dgram, dgram.Length);
client.Send(dgram, dgram.Length);
client.Send(dgram, dgram.Length);
client.Send(dgram, dgram.Length);
client.Send(dgram, dgram.Length);
// 메시지 전송 시도
for (int i = 0; i < 5; i++)
{
client.Send(dgram, dgram.Length);
}
}
catch (Exception e)
{
Debug.LogError($"[iFacialMocap] 메시지 전송 실패: {e.Message}");
}
catch { }
}
// Update is called once per frame
@ -122,17 +133,20 @@ public class UnityRecieve_FACEMOTION3D_and_iFacialMocap : MonoBehaviour
void SetBlendShapeWeightFromStrArray(string[] strArray2)
{
string mappedShapeName = strArray2[0].Replace("_R", "Right").Replace("_L", "Left");
float weight = float.Parse(strArray2[1], CultureInfo.InvariantCulture);
foreach (SkinnedMeshRenderer meshTarget in meshTargetList)
if (faceMeshRenderers != null)
{
var shared_mesh = meshTarget.sharedMesh;
int index = shared_mesh.GetBlendShapeIndex(mappedShapeName);
if (index > -1)
foreach (var meshRenderer in faceMeshRenderers)
{
meshTarget.SetBlendShapeWeight(index, weight);
if (meshRenderer != null && meshRenderer.sharedMesh != null)
{
int index = meshRenderer.sharedMesh.GetBlendShapeIndex(mappedShapeName);
if (index > -1)
{
meshRenderer.SetBlendShapeWeight(index, weight);
}
}
}
}
}
@ -174,31 +188,22 @@ public class UnityRecieve_FACEMOTION3D_and_iFacialMocap : MonoBehaviour
if (strArray2.Length == 2)
{
string[] commaList = strArray2[1].Split(',');
if (strArray2[0] == "head")
if (strArray2[0] == "head" && headBone != null)
{
foreach (GameObject headObject in headObjectArray)
{
headObject.transform.localRotation = Quaternion.Euler(float.Parse(commaList[0], CultureInfo.InvariantCulture), -float.Parse(commaList[1], CultureInfo.InvariantCulture), -float.Parse(commaList[2], CultureInfo.InvariantCulture));
}
headBone.localRotation = Quaternion.Euler(float.Parse(commaList[0], CultureInfo.InvariantCulture), -float.Parse(commaList[1], CultureInfo.InvariantCulture), -float.Parse(commaList[2], CultureInfo.InvariantCulture));
foreach (GameObject headPositionObject in headPositionObjectArray)
if (headPositionObject != null)
{
headPositionObject.transform.localPosition = new Vector3(-float.Parse(commaList[3], CultureInfo.InvariantCulture), float.Parse(commaList[4], CultureInfo.InvariantCulture), float.Parse(commaList[5], CultureInfo.InvariantCulture));
headPositionObject.localPosition = new Vector3(-float.Parse(commaList[3], CultureInfo.InvariantCulture), float.Parse(commaList[4], CultureInfo.InvariantCulture), float.Parse(commaList[5], CultureInfo.InvariantCulture));
}
}
else if (strArray2[0] == "rightEye")
else if (strArray2[0] == "rightEye" && rightEyeBone != null)
{
foreach (GameObject rightEyeObject in rightEyeObjectArray)
{
rightEyeObject.transform.localRotation = Quaternion.Euler(float.Parse(commaList[0], CultureInfo.InvariantCulture), -float.Parse(commaList[1], CultureInfo.InvariantCulture), float.Parse(commaList[2], CultureInfo.InvariantCulture));
}
rightEyeBone.localRotation = Quaternion.Euler(float.Parse(commaList[0], CultureInfo.InvariantCulture), -float.Parse(commaList[1], CultureInfo.InvariantCulture), float.Parse(commaList[2], CultureInfo.InvariantCulture));
}
else if (strArray2[0] == "leftEye")
else if (strArray2[0] == "leftEye" && leftEyeBone != null)
{
foreach (GameObject leftEyeObject in leftEyeObjectArray)
{
leftEyeObject.transform.localRotation = Quaternion.Euler(float.Parse(commaList[0], CultureInfo.InvariantCulture), -float.Parse(commaList[1], CultureInfo.InvariantCulture), float.Parse(commaList[2], CultureInfo.InvariantCulture));
}
leftEyeBone.localRotation = Quaternion.Euler(float.Parse(commaList[0], CultureInfo.InvariantCulture), -float.Parse(commaList[1], CultureInfo.InvariantCulture), float.Parse(commaList[2], CultureInfo.InvariantCulture));
}
}
}
@ -211,68 +216,7 @@ public class UnityRecieve_FACEMOTION3D_and_iFacialMocap : MonoBehaviour
void FindGameObjectsInsideUnitySettings()
{
//Find BlendShape Objects
meshTargetList = new List<SkinnedMeshRenderer>();
GameObject faceObjGrp = GameObject.Find(faceObjectGroupName);
if (faceObjGrp != null)
{
List<GameObject> list = FM3D_and_iFacialMocap_GetAllChildren.GetAll(faceObjGrp);
foreach (GameObject obj in list)
{
meshTarget = obj.GetComponent<SkinnedMeshRenderer>();
if (meshTarget != null)
{
if (HasBlendShapes(meshTarget) == true)
{
meshTargetList.Add(meshTarget);
}
}
}
}
//Find Bone Objects
headObjectArray = new List<GameObject>();
foreach (string headString in headBoneName.Split(','))
{
GameObject headObject = GameObject.Find(headString);
if (headObject != null)
{
headObjectArray.Add(headObject);
}
}
rightEyeObjectArray = new List<GameObject>();
foreach (string rightEyeString in rightEyeBoneName.Split(','))
{
GameObject rightEyeObject = GameObject.Find(rightEyeString);
if (rightEyeObject != null)
{
rightEyeObjectArray.Add(rightEyeObject);
}
}
leftEyeObjectArray = new List<GameObject>();
foreach (string leftEyeString in leftEyeBoneName.Split(','))
{
GameObject leftEyeObject = GameObject.Find(leftEyeString);
if (leftEyeObject != null)
{
leftEyeObjectArray.Add(leftEyeObject);
}
}
headPositionObjectArray = new List<GameObject>();
foreach (string headPositionString in headPositionObjectName.Split(','))
{
GameObject headPositionObject = GameObject.Find(headPositionString);
if (headPositionObject != null)
{
headPositionObjectArray.Add(headPositionObject);
}
}
// 모든 Transform 참조는 이미 인스펙터에서 할당되므로 추가 초기화가 필요 없음
}
void ThreadMethod()
@ -289,8 +233,16 @@ public class UnityRecieve_FACEMOTION3D_and_iFacialMocap : MonoBehaviour
byte[] data = udp.Receive(ref remoteEP);
messageString = Encoding.ASCII.GetString(data);
}
catch
catch (SocketException e)
{
if (e.SocketErrorCode != SocketError.TimedOut)
{
Debug.LogError($"[iFacialMocap] 데이터 수신 오류: {e.Message}");
}
}
catch (Exception e)
{
Debug.LogError($"[iFacialMocap] 예상치 못한 오류: {e.Message}");
}
do

View File

@ -24,7 +24,6 @@ using NaturalPoint;
using NaturalPoint.NatNetLib;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
using static TMPro.SpriteAssetUtilities.TexturePacker_JsonArray;
@ -341,7 +340,6 @@ public class OptitrackStreamingClient : MonoBehaviour
private bool m_hasDrawnCameras = false;
private bool m_hasDrawnForcePlates = false;
private bool m_subscribedToMarkers = false;
private bool m_subscribedToTMarkMarkers = false; // trained markerset added
private OptitrackHiResTimer.Timestamp m_lastFrameDeliveryTimestamp;
private Coroutine m_connectionHealthCoroutine = null;
@ -611,7 +609,7 @@ public class OptitrackStreamingClient : MonoBehaviour
/// <returns>An arbitrary OptitrackClient from the scene, or null if none are found.</returns>
public static OptitrackStreamingClient FindDefaultClient()
{
OptitrackStreamingClient[] allClients = FindObjectsOfType<OptitrackStreamingClient>();
OptitrackStreamingClient[] allClients = FindObjectsByType<OptitrackStreamingClient>(FindObjectsSortMode.None);
if ( allClients.Length == 0 )
{

Binary file not shown.

BIN
Assets/Scenes/Development scene.unity (Stored with Git LFS)

Binary file not shown.

View File

@ -3,6 +3,7 @@ using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using Klak.Spout;
using Klak.Ndi;
using System;
// 출력 방식 열거형
public enum OutputMethod
@ -304,6 +305,7 @@ public class AlphaRecodingRenderPass : ScriptableRenderPass
m_ShaderTexture = shaderTexture;
}
[Obsolete("This method is obsolete. Use the new Render Graph API instead.")]
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
try
@ -315,8 +317,11 @@ public class AlphaRecodingRenderPass : ScriptableRenderPass
try
{
// Update cameraColorTargetHandle usage
var colorTarget = renderingData.cameraData.renderer.cameraColorTargetHandle;
// 최종 렌더링 결과를 가져옵니다
RenderTargetIdentifier source = renderingData.cameraData.renderer.cameraColorTargetHandle;
RenderTargetIdentifier source = colorTarget;
cmd.Blit(source, m_ShaderCameraTexture);
// ShaderCameraTexture를 ShaderContral의 _MainTex에 할당

View File

@ -160,11 +160,7 @@ public class StreamingleAvatarExporter : EditorWindow
};
// 빌드 옵션 설정
BuildAssetBundleOptions options = BuildAssetBundleOptions.ForceRebuildAssetBundle
| BuildAssetBundleOptions.StrictMode
| BuildAssetBundleOptions.DeterministicAssetBundle
| BuildAssetBundleOptions.DisableLoadAssetByFileName
| BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension;
BuildAssetBundleOptions options = BuildAssetBundleOptions.None;
// AssetBundle 빌드
BuildPipeline.BuildAssetBundles(

View File

@ -50,7 +50,7 @@ public class CameraManagerEditor : Editor
if (GUILayout.Button("새 프리셋 추가", GUILayout.Height(30)))
{
// Scene에 있는 CinemachineCamera 컴포넌트를 가져와서 새 프리셋 생성
var newCamera = GameObject.FindObjectOfType<CinemachineCamera>();
var newCamera = FindFirstObjectByType<CinemachineCamera>();
if (newCamera != null)
{
manager.cameraPresets.Add(new CameraManager.CameraPreset(newCamera));

BIN
Packages/manifest.json (Stored with Git LFS)

Binary file not shown.

BIN
Packages/packages-lock.json (Stored with Git LFS)

Binary file not shown.