Add other facial morph support ,bug fix
This commit is contained in:
@@ -23405,8 +23405,8 @@ MonoBehaviour:
|
|||||||
m_TargetGraphic: {fileID: 1882365343}
|
m_TargetGraphic: {fileID: 1882365343}
|
||||||
m_HandleRect: {fileID: 1882365342}
|
m_HandleRect: {fileID: 1882365342}
|
||||||
m_Direction: 2
|
m_Direction: 2
|
||||||
m_Value: 0.9999985
|
m_Value: 1
|
||||||
m_Size: 0.9257714
|
m_Size: 0.92577153
|
||||||
m_NumberOfSteps: 0
|
m_NumberOfSteps: 0
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
@@ -36794,7 +36794,7 @@ MonoBehaviour:
|
|||||||
m_StringArgument:
|
m_StringArgument:
|
||||||
m_BoolArgument: 0
|
m_BoolArgument: 0
|
||||||
m_CallState: 2
|
m_CallState: 2
|
||||||
- m_Target: {fileID: 1923521930}
|
- m_Target: {fileID: 1443017299}
|
||||||
m_TargetAssemblyTypeName: UnityEngine.UI.Selectable, UnityEngine.UI
|
m_TargetAssemblyTypeName: UnityEngine.UI.Selectable, UnityEngine.UI
|
||||||
m_MethodName: set_interactable
|
m_MethodName: set_interactable
|
||||||
m_Mode: 6
|
m_Mode: 6
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ public class UmaContainer : MonoBehaviour
|
|||||||
public List<GameObject> RightMangaObject = new List<GameObject>();
|
public List<GameObject> RightMangaObject = new List<GameObject>();
|
||||||
|
|
||||||
[Header("Tear")]
|
[Header("Tear")]
|
||||||
public List<GameObject> TearObjects_0 = new List<GameObject>();
|
public GameObject TearPrefab_0;
|
||||||
public List<GameObject> TearObjects_1 = new List<GameObject>();
|
public GameObject TearPrefab_1;
|
||||||
|
public List<TearController> TearControllers = new List<TearController>();
|
||||||
|
|
||||||
[Header("Generic")]
|
[Header("Generic")]
|
||||||
public bool IsGeneric = false;
|
public bool IsGeneric = false;
|
||||||
@@ -192,39 +193,45 @@ public class UmaContainer : MonoBehaviour
|
|||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
if (TrackTarget && EnableEyeTracking && !isAnimatorControl && !IsMini)
|
if (!IsMini)
|
||||||
{
|
{
|
||||||
var targetPosotion = TrackTarget.transform.position - HeadBone.transform.up*EyeHeight;
|
if (TrackTarget && EnableEyeTracking && !isAnimatorControl)
|
||||||
var deltaPos = HeadBone.transform.InverseTransformPoint(targetPosotion);
|
{
|
||||||
var deltaRotation = Quaternion.LookRotation(deltaPos.normalized, HeadBone.transform.up).eulerAngles;
|
var targetPosotion = TrackTarget.transform.position - HeadBone.transform.up * EyeHeight;
|
||||||
if (deltaRotation.x > 180) deltaRotation.x -= 360;
|
var deltaPos = HeadBone.transform.InverseTransformPoint(targetPosotion);
|
||||||
if (deltaRotation.y > 180) deltaRotation.y -= 360;
|
var deltaRotation = Quaternion.LookRotation(deltaPos.normalized, HeadBone.transform.up).eulerAngles;
|
||||||
|
if (deltaRotation.x > 180) deltaRotation.x -= 360;
|
||||||
|
if (deltaRotation.y > 180) deltaRotation.y -= 360;
|
||||||
|
|
||||||
var finalRotation = new Vector2(Mathf.Clamp(deltaRotation.y / 35,-1,1), Mathf.Clamp(-deltaRotation.x / 25, -1, 1));//Limited to the angle of view
|
var finalRotation = new Vector2(Mathf.Clamp(deltaRotation.y / 35, -1, 1), Mathf.Clamp(-deltaRotation.x / 25, -1, 1));//Limited to the angle of view
|
||||||
FaceDrivenKeyTarget.SetEyeRange(finalRotation.x, finalRotation.y, finalRotation.x, -finalRotation.y);
|
FaceDrivenKeyTarget.SetEyeRange(finalRotation.x, finalRotation.y, finalRotation.x, -finalRotation.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAnimatorControl && !IsMini)
|
|
||||||
{
|
|
||||||
FaceDrivenKeyTarget.ProcessLocator();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsMini && FaceMaterial)
|
|
||||||
{
|
|
||||||
if (isAnimatorControl)
|
if (isAnimatorControl)
|
||||||
{
|
{
|
||||||
FaceMaterial.SetVector("_FaceForward", Vector3.zero);
|
FaceDrivenKeyTarget.ProcessLocator();
|
||||||
FaceMaterial.SetVector("_FaceUp", Vector3.zero);
|
|
||||||
FaceMaterial.SetVector("_FaceCenterPos", Vector3.zero);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (FaceMaterial)
|
||||||
{
|
{
|
||||||
//Used to calculate facial shadows
|
if (isAnimatorControl)
|
||||||
FaceMaterial.SetVector("_FaceForward", HeadBone.transform.forward);
|
{
|
||||||
FaceMaterial.SetVector("_FaceUp", HeadBone.transform.up);
|
FaceMaterial.SetVector("_FaceForward", Vector3.zero);
|
||||||
FaceMaterial.SetVector("_FaceCenterPos", HeadBone.transform.position);
|
FaceMaterial.SetVector("_FaceUp", Vector3.zero);
|
||||||
|
FaceMaterial.SetVector("_FaceCenterPos", Vector3.zero);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Used to calculate facial shadows
|
||||||
|
FaceMaterial.SetVector("_FaceForward", HeadBone.transform.forward);
|
||||||
|
FaceMaterial.SetVector("_FaceUp", HeadBone.transform.up);
|
||||||
|
FaceMaterial.SetVector("_FaceCenterPos", HeadBone.transform.position);
|
||||||
|
}
|
||||||
|
FaceMaterial.SetFloat("_faceShadowEndY", HeadBone.transform.position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TearControllers.ForEach(a => a.UpdateOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -298,24 +298,30 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
CurrentUMAContainer.LeftMangaObject.Add(leftObj);
|
CurrentUMAContainer.LeftMangaObject.Add(leftObj);
|
||||||
|
|
||||||
var RightObj = Instantiate(obj, eyeLocator_R.transform);
|
var RightObj = Instantiate(obj, eyeLocator_R.transform);
|
||||||
bool invert = false;
|
|
||||||
if (RightObj.TryGetComponent<AssetHolder>(out var holder))
|
if (RightObj.TryGetComponent<AssetHolder>(out var holder))
|
||||||
{
|
{
|
||||||
if (holder._assetTableValue["invert"] > 0)
|
if (holder._assetTableValue["invert"] > 0)
|
||||||
invert = true;
|
RightObj.transform.localScale = new Vector3(-1, 1, 1);
|
||||||
}
|
}
|
||||||
new List<Renderer>(RightObj.GetComponentsInChildren<Renderer>()).ForEach(a => {
|
new List<Renderer>(RightObj.GetComponentsInChildren<Renderer>()).ForEach(a => { a.material.renderQueue = -1; });
|
||||||
a.material.renderQueue = -1;
|
|
||||||
if (invert) a.material.mainTextureScale = new Vector2(-1, 1);
|
|
||||||
});
|
|
||||||
CurrentUMAContainer.RightMangaObject.Add(RightObj);
|
CurrentUMAContainer.RightMangaObject.Add(RightObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
var tearEntry = Main.AbChara.FindAll(a => a.Name.StartsWith("3d/chara/common/tear/")&& a.Name.Contains("pfb_chr_tear"));
|
var tearEntry = Main.AbChara.FindAll(a => a.Name.StartsWith("3d/chara/common/tear/") && a.Name.Contains("pfb_chr_tear"));
|
||||||
if (tearEntry.Count > 0)
|
if (tearEntry.Count > 0)
|
||||||
{
|
{
|
||||||
tearEntry.ForEach(a => RecursiveLoadAsset(a));
|
tearEntry.ForEach(a => RecursiveLoadAsset(a));
|
||||||
}
|
}
|
||||||
|
if (CurrentUMAContainer.TearPrefab_0 && CurrentUMAContainer.TearPrefab_1)
|
||||||
|
{
|
||||||
|
var p0 = CurrentUMAContainer.TearPrefab_0;
|
||||||
|
var p1 = CurrentUMAContainer.TearPrefab_1;
|
||||||
|
var t = headBone.transform;
|
||||||
|
CurrentUMAContainer.TearControllers.Add(new TearController(t, Instantiate(p0, t), Instantiate(p1, t), 0, 1));
|
||||||
|
CurrentUMAContainer.TearControllers.Add(new TearController(t, Instantiate(p0, t), Instantiate(p1, t), 0, 0));
|
||||||
|
CurrentUMAContainer.TearControllers.Add(new TearController(t, Instantiate(p0, t), Instantiate(p1, t), 1, 1));
|
||||||
|
CurrentUMAContainer.TearControllers.Add(new TearController(t, Instantiate(p0, t), Instantiate(p1, t), 1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
var firsehead = CurrentUMAContainer.Head;
|
var firsehead = CurrentUMAContainer.Head;
|
||||||
var faceDriven = firsehead.GetComponent<AssetHolder>()._assetTable["facial_target"] as FaceDrivenKeyTarget;
|
var faceDriven = firsehead.GetComponent<AssetHolder>()._assetTable["facial_target"] as FaceDrivenKeyTarget;
|
||||||
@@ -338,7 +344,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
CurrentUMAContainer.EyeHeight = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTableValue["head_center_offset_y"];
|
CurrentUMAContainer.EyeHeight = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTableValue["head_center_offset_y"];
|
||||||
CurrentUMAContainer.MergeModel();
|
CurrentUMAContainer.MergeModel();
|
||||||
CurrentUMAContainer.Initialize();
|
CurrentUMAContainer.Initialize();
|
||||||
|
|
||||||
CurrentUMAContainer.SetHeight(Convert.ToInt32(CurrentUMAContainer.CharaData["scale"]));
|
CurrentUMAContainer.SetHeight(Convert.ToInt32(CurrentUMAContainer.CharaData["scale"]));
|
||||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{id}_00_idle01_loop")));
|
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{id}_00_idle01_loop")));
|
||||||
}
|
}
|
||||||
@@ -713,7 +719,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
LoadAnimation(aClip);
|
LoadAnimation(aClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentLiveContainer|| aClip.name.Contains("tear"))
|
if (CurrentLiveContainer || aClip.name.Contains("tear"))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1027,57 +1033,52 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
|
|
||||||
private void LoadTear(GameObject go)
|
private void LoadTear(GameObject go)
|
||||||
{
|
{
|
||||||
//WIP
|
|
||||||
//if (CurrentUMAContainer)
|
|
||||||
//{
|
|
||||||
// var headBone = (GameObject)CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTable["head"];
|
|
||||||
// var attachBone_2_L = headBone.transform.Find("Eye_tear_attach_02_L");
|
|
||||||
// var attachBone_2_R = headBone.transform.Find("Eye_tear_attach_02_R");
|
|
||||||
// var attachBone_3_L = headBone.transform.Find("Eye_tear_attach_03_L");
|
|
||||||
// var attachBone_3_R = headBone.transform.Find("Eye_tear_attach_03_R");
|
|
||||||
// var ani = go.GetComponent<Animator>();
|
|
||||||
// var controller = new AnimatorOverrideController(ani.runtimeAnimatorController);
|
|
||||||
// controller["anm_tear000_00"] = go.GetComponent<AssetHolder>()._assetTable["default_animation"] as AnimationClip;
|
|
||||||
// ani.runtimeAnimatorController = controller;
|
|
||||||
|
|
||||||
// if (go.name.EndsWith("000"))
|
if (CurrentUMAContainer)
|
||||||
// {
|
{
|
||||||
// for(int i = 0; i < 4; i++)
|
if (go.name.EndsWith("000"))
|
||||||
// {
|
{
|
||||||
// var obj = Instantiate(go, headBone.transform);
|
CurrentUMAContainer.TearPrefab_0 = go;
|
||||||
// var attachBone = (i % 2 == 0 ? attachBone_3_L : attachBone_3_R);
|
}
|
||||||
// obj.transform.SetPositionAndRotation(attachBone.TransformPoint(Vector3.zero), attachBone.transform.rotation);
|
else if (go.name.EndsWith("001"))
|
||||||
// CurrentUMAContainer.TearObjects_0.Add(obj);
|
{
|
||||||
// }
|
CurrentUMAContainer.TearPrefab_1 = go;
|
||||||
// }
|
}
|
||||||
// else if(go.name.EndsWith("001"))
|
}
|
||||||
// {
|
|
||||||
// for (int i = 0; i < 4; i++)
|
|
||||||
// {
|
|
||||||
// var obj = Instantiate(go, headBone.transform);
|
|
||||||
// var attachBone = (i % 2 == 0 ? attachBone_2_L : attachBone_2_R);
|
|
||||||
// obj.transform.SetPositionAndRotation(attachBone.TransformPoint(Vector3.zero), attachBone.transform.rotation);
|
|
||||||
// CurrentUMAContainer.TearObjects_1.Add(obj);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadAnimation(AnimationClip clip)
|
private void LoadAnimation(AnimationClip clip)
|
||||||
{
|
{
|
||||||
bool needTransit = false;
|
|
||||||
if (clip.name.EndsWith("_S"))
|
if (clip.name.EndsWith("_S"))
|
||||||
{
|
{
|
||||||
|
CurrentUMAContainer.UpBodyReset();
|
||||||
CurrentUMAContainer.OverrideController["clip_s"] = clip;
|
CurrentUMAContainer.OverrideController["clip_s"] = clip;
|
||||||
}
|
}
|
||||||
else if (clip.name.EndsWith("_E"))
|
else if (clip.name.EndsWith("_E"))
|
||||||
{
|
{
|
||||||
|
CurrentUMAContainer.UpBodyReset();
|
||||||
CurrentUMAContainer.OverrideController["clip_e"] = clip;
|
CurrentUMAContainer.OverrideController["clip_e"] = clip;
|
||||||
}
|
}
|
||||||
else if (clip.name.EndsWith("_loop"))
|
else if (clip.name.EndsWith("_loop"))
|
||||||
{
|
{
|
||||||
var motion_s = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith(clip.name.Replace("_loop", "_s")));
|
CurrentUMAContainer.UpBodyReset();
|
||||||
var motion_e = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith(CurrentUMAContainer.OverrideController["clip_2"].name.Replace("_loop", "_e")));
|
UmaDatabaseEntry motion_e = null, motion_s = null;
|
||||||
|
if (clip.name.EndsWith("_loop"))
|
||||||
|
{
|
||||||
|
motion_s = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith(clip.name.Replace("_loop", "_s")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CurrentUMAContainer.OverrideController["clip_2"].name.EndsWith("_loop"))
|
||||||
|
{
|
||||||
|
motion_e = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith(CurrentUMAContainer.OverrideController["clip_2"].name.Replace("_loop", "_e")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CurrentUMAContainer.isAnimatorControl && CurrentUMAContainer.FaceDrivenKeyTarget)
|
||||||
|
{
|
||||||
|
CurrentUMAContainer.FaceDrivenKeyTarget.ResetLocator();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool needTransit = false;
|
||||||
needTransit = (motion_s != null && motion_e != null);
|
needTransit = (motion_s != null && motion_e != null);
|
||||||
if (needTransit)
|
if (needTransit)
|
||||||
{
|
{
|
||||||
@@ -1097,6 +1098,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
else if (clip.name.Contains("tail"))
|
else if (clip.name.Contains("tail"))
|
||||||
{
|
{
|
||||||
if (CurrentUMAContainer.IsMini) return;
|
if (CurrentUMAContainer.IsMini) return;
|
||||||
|
CurrentUMAContainer.UpBodyReset();
|
||||||
CurrentUMAContainer.OverrideController["clip_t"] = clip;
|
CurrentUMAContainer.OverrideController["clip_t"] = clip;
|
||||||
CurrentUMAContainer.UmaAnimator.Play("motion_t", 1, 0);
|
CurrentUMAContainer.UmaAnimator.Play("motion_t", 1, 0);
|
||||||
}
|
}
|
||||||
@@ -1175,7 +1177,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
var nextMotion = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"{param[0]}_{param[1]}_{param[2]}_{param[3]}_0{index}"));
|
var nextMotion = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"{param[0]}_{param[1]}_{param[2]}_{param[3]}_0{index}"));
|
||||||
var aevent = new AnimationEvent
|
var aevent = new AnimationEvent
|
||||||
{
|
{
|
||||||
time = clip.length*0.99f,
|
time = clip.length * 0.99f,
|
||||||
stringParameter = (nextMotion != null ? nextMotion.Name : null),
|
stringParameter = (nextMotion != null ? nextMotion.Name : null),
|
||||||
functionName = (nextMotion != null ? "SetNextAnimationCut" : "SetEndAnimationCut")
|
functionName = (nextMotion != null ? "SetNextAnimationCut" : "SetEndAnimationCut")
|
||||||
};
|
};
|
||||||
@@ -1193,7 +1195,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
SetPreviewCamera(null);
|
SetPreviewCamera(null);
|
||||||
|
|
||||||
CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime);
|
CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime);
|
||||||
CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next");
|
CurrentUMAContainer.UmaAnimator.SetTrigger("next");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ public class UmaViewerUI : MonoBehaviour
|
|||||||
foreach(var prop in extraMorph.BindProperties)
|
foreach(var prop in extraMorph.BindProperties)
|
||||||
{
|
{
|
||||||
var container = Instantiate(UmaContainerSliderPrefab, TargetList.content).GetComponent<UmaUIContainer>();
|
var container = Instantiate(UmaContainerSliderPrefab, TargetList.content).GetComponent<UmaUIContainer>();
|
||||||
container.Name = $"{morph.name}_{extraMorph.BindProperties.IndexOf(prop)}_{prop.Type}";
|
container.Name = $"{morph.locator.name}({prop.Type})";
|
||||||
container.Slider.value = prop.Value;
|
container.Slider.value = prop.Value;
|
||||||
switch (prop.Type)
|
switch (prop.Type)
|
||||||
{
|
{
|
||||||
@@ -243,15 +243,25 @@ public class UmaViewerUI : MonoBehaviour
|
|||||||
container.Slider.maxValue = prop.BindPrefab.Count/2 - 1;
|
container.Slider.maxValue = prop.BindPrefab.Count/2 - 1;
|
||||||
container.Slider.minValue = 0;
|
container.Slider.minValue = 0;
|
||||||
break;
|
break;
|
||||||
case BindProperty.BindType.Bool:
|
case BindProperty.BindType.Enable:
|
||||||
|
case BindProperty.BindType.TearSelect:
|
||||||
|
case BindProperty.BindType.TearSide:
|
||||||
container.Slider.wholeNumbers = true;
|
container.Slider.wholeNumbers = true;
|
||||||
container.Slider.maxValue = 1;
|
container.Slider.maxValue = 1;
|
||||||
container.Slider.minValue = 0;
|
container.Slider.minValue = 0;
|
||||||
break;
|
break;
|
||||||
|
case BindProperty.BindType.TearWeight:
|
||||||
|
container.Slider.maxValue = 1;
|
||||||
|
container.Slider.minValue = 0;
|
||||||
|
break;
|
||||||
|
case BindProperty.BindType.TearSpeed:
|
||||||
|
container.Slider.maxValue = 2;
|
||||||
|
container.Slider.minValue = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
container.Slider.onValueChanged.AddListener((a) => {
|
container.Slider.onValueChanged.AddListener((a) => {
|
||||||
target.ChangeMorphWeight(prop, a);
|
target.ChangeMorphWeight(prop, a);
|
||||||
if(prop.Type == BindProperty.BindType.Bool&& morph.name.Contains("Manga"))
|
if(prop.Type == BindProperty.BindType.Enable&& morph.name.Contains("Manga"))
|
||||||
{
|
{
|
||||||
target.ChangeMorphWeight(target.EyeMorphs[42], container.Slider.value > 0 ? 1 : 0);
|
target.ChangeMorphWeight(target.EyeMorphs[42], container.Slider.value > 0 ? 1 : 0);
|
||||||
target.ChangeMorphWeight(target.EyeMorphs[43], container.Slider.value > 0 ? 1 : 0);
|
target.ChangeMorphWeight(target.EyeMorphs[43], container.Slider.value > 0 ? 1 : 0);
|
||||||
|
|||||||
@@ -258,10 +258,49 @@ namespace Gallop
|
|||||||
FaceMangaMorph.BindProperties.Add(new BindProperty()
|
FaceMangaMorph.BindProperties.Add(new BindProperty()
|
||||||
{
|
{
|
||||||
Part = BindProperty.LocatorPart.ScaX,
|
Part = BindProperty.LocatorPart.ScaX,
|
||||||
Type = BindProperty.BindType.Bool,
|
Type = BindProperty.BindType.Enable,
|
||||||
BindPrefab = mangaObjects
|
BindPrefab = mangaObjects
|
||||||
});
|
});
|
||||||
OtherMorphs.Add(FaceMangaMorph);
|
OtherMorphs.Add(FaceMangaMorph);
|
||||||
|
|
||||||
|
foreach(var tear in Container.TearControllers)
|
||||||
|
{
|
||||||
|
var index = Container.TearControllers.IndexOf(tear);
|
||||||
|
FacialExtraMorph FaceTearMorph = new FacialExtraMorph()
|
||||||
|
{
|
||||||
|
name = $"Tear{index}_Ctrl",
|
||||||
|
locator = DrivenKeyLocator.Find($"Tear{index}_Ctrl")
|
||||||
|
};
|
||||||
|
FaceTearMorph.BindProperties.Add(new BindProperty()
|
||||||
|
{
|
||||||
|
Part = BindProperty.LocatorPart.ScaX,
|
||||||
|
Type = BindProperty.BindType.TearWeight,
|
||||||
|
BindTearController = tear,
|
||||||
|
Value = tear.Weight
|
||||||
|
});
|
||||||
|
FaceTearMorph.BindProperties.Add(new BindProperty()
|
||||||
|
{
|
||||||
|
Part = BindProperty.LocatorPart.PosY,
|
||||||
|
Type = BindProperty.BindType.TearSide,
|
||||||
|
BindTearController = tear,
|
||||||
|
Value = tear.CurrentDir
|
||||||
|
});
|
||||||
|
FaceTearMorph.BindProperties.Add(new BindProperty()
|
||||||
|
{
|
||||||
|
Part = BindProperty.LocatorPart.ScaY,
|
||||||
|
Type = BindProperty.BindType.TearSelect,
|
||||||
|
BindTearController = tear,
|
||||||
|
Value = tear.CurrenObject
|
||||||
|
});
|
||||||
|
FaceTearMorph.BindProperties.Add(new BindProperty()
|
||||||
|
{
|
||||||
|
Part = BindProperty.LocatorPart.ScaZ,
|
||||||
|
Type = BindProperty.BindType.TearSpeed,
|
||||||
|
BindTearController = tear,
|
||||||
|
Value = tear.Speed
|
||||||
|
});
|
||||||
|
OtherMorphs.Add(FaceTearMorph);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupAnimator()
|
public void SetupAnimator()
|
||||||
@@ -380,12 +419,24 @@ namespace Gallop
|
|||||||
property.BindPrefab.ForEach(a =>
|
property.BindPrefab.ForEach(a =>
|
||||||
a.SetActive(val + count < property.BindPrefab.Count && (val == property.BindPrefab.IndexOf(a) || val + count == property.BindPrefab.IndexOf(a))));
|
a.SetActive(val + count < property.BindPrefab.Count && (val == property.BindPrefab.IndexOf(a) || val + count == property.BindPrefab.IndexOf(a))));
|
||||||
break;
|
break;
|
||||||
case BindProperty.BindType.Bool:
|
case BindProperty.BindType.Enable:
|
||||||
if (property.Value <= 0)
|
if (property.Value <= 0)
|
||||||
{
|
{
|
||||||
property.BindPrefab.ForEach(a =>a.SetActive(false));
|
property.BindPrefab.ForEach(a =>a.SetActive(false));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case BindProperty.BindType.TearSide:
|
||||||
|
property.BindTearController.SetDir((int)property.Value);
|
||||||
|
break;
|
||||||
|
case BindProperty.BindType.TearWeight:
|
||||||
|
property.BindTearController.SetWegiht(property.Value);
|
||||||
|
break;
|
||||||
|
case BindProperty.BindType.TearSelect:
|
||||||
|
property.BindTearController.SetObject((int)property.Value);
|
||||||
|
break;
|
||||||
|
case BindProperty.BindType.TearSpeed:
|
||||||
|
property.BindTearController.SetSpeed(property.Value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -491,12 +542,6 @@ namespace Gallop
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
LeftEyeXrange.weight = -(EyeballCtrl_L_Locator.transform.localPosition.x * -100 + EyeballCtrl_All_Locator.transform.localPosition.x * -100);
|
|
||||||
RightEyeXrange.weight = -(EyeballCtrl_R_Locator.transform.localPosition.x * -100 + EyeballCtrl_All_Locator.transform.localPosition.x * -100);
|
|
||||||
|
|
||||||
LeftEyeYrange.weight = -(EyeballCtrl_L_Locator.transform.localPosition.y * -100 + EyeballCtrl_All_Locator.transform.localPosition.y * -100);
|
|
||||||
RightEyeYrange.weight = (EyeballCtrl_R_Locator.transform.localPosition.y * -100 + EyeballCtrl_All_Locator.transform.localPosition.y * -100);
|
|
||||||
|
|
||||||
OtherMorphs.ForEach(morph =>
|
OtherMorphs.ForEach(morph =>
|
||||||
{
|
{
|
||||||
morph.BindProperties.ForEach(property =>
|
morph.BindProperties.ForEach(property =>
|
||||||
@@ -505,12 +550,19 @@ namespace Gallop
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
LeftEyeXrange.weight = -(EyeballCtrl_L_Locator.transform.localPosition.x * -100 + EyeballCtrl_All_Locator.transform.localPosition.x * -100);
|
||||||
|
RightEyeXrange.weight = -(EyeballCtrl_R_Locator.transform.localPosition.x * -100 + EyeballCtrl_All_Locator.transform.localPosition.x * -100);
|
||||||
|
|
||||||
|
LeftEyeYrange.weight = -(EyeballCtrl_L_Locator.transform.localPosition.y * -100 + EyeballCtrl_All_Locator.transform.localPosition.y * -100);
|
||||||
|
RightEyeYrange.weight = (EyeballCtrl_R_Locator.transform.localPosition.y * -100 + EyeballCtrl_All_Locator.transform.localPosition.y * -100);
|
||||||
|
|
||||||
ChangeMorph();
|
ChangeMorph();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetLocator()
|
public void ResetLocator()
|
||||||
{
|
{
|
||||||
Container.UmaFaceAnimator.Rebind();
|
Container.UmaFaceAnimator.Rebind();
|
||||||
|
ProcessLocator();
|
||||||
ChangeMorph();
|
ChangeMorph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,15 @@ namespace Gallop
|
|||||||
Select,
|
Select,
|
||||||
EyeSelect,
|
EyeSelect,
|
||||||
Texture,
|
Texture,
|
||||||
Bool
|
Enable,
|
||||||
|
TearSide,
|
||||||
|
TearWeight,
|
||||||
|
TearSelect,
|
||||||
|
TearSpeed
|
||||||
}
|
}
|
||||||
public Material BindMaterial;
|
public Material BindMaterial;
|
||||||
public Texture BindTexture;
|
public Texture BindTexture;
|
||||||
|
public TearController BindTearController;
|
||||||
public List<GameObject> BindPrefab = new List<GameObject>();
|
public List<GameObject> BindPrefab = new List<GameObject>();
|
||||||
public string PropertyName;
|
public string PropertyName;
|
||||||
public LocatorPart Part;
|
public LocatorPart Part;
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
using Gallop;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class TearController
|
||||||
|
{
|
||||||
|
public GameObject TearObject_0;
|
||||||
|
public GameObject TearObject_1;
|
||||||
|
|
||||||
|
public Material CurrentMaterial;
|
||||||
|
public Material TearMaterial_0;
|
||||||
|
public Material TearMaterial_1;
|
||||||
|
|
||||||
|
public int CurrenObject;
|
||||||
|
public int CurrentDir;
|
||||||
|
public float Weight;
|
||||||
|
public float Speed = 1;
|
||||||
|
|
||||||
|
private Animator CurrentAnimator;
|
||||||
|
private Animator Animator_0;
|
||||||
|
private Animator Animator_1;
|
||||||
|
|
||||||
|
private Transform AttachBone_2_L;
|
||||||
|
private Transform AttachBone_2_R;
|
||||||
|
private Transform AttachBone_3_L;
|
||||||
|
private Transform AttachBone_3_R;
|
||||||
|
|
||||||
|
private AssetHolder CurrentAssetHolder;
|
||||||
|
private AssetHolder AssetHolder0;
|
||||||
|
private AssetHolder AssetHolder1;
|
||||||
|
|
||||||
|
bool intialized;
|
||||||
|
public TearController(Transform headBone, GameObject tearPrefab_0, GameObject tearPrefab_1, int dir, int currentObject)
|
||||||
|
{
|
||||||
|
AttachBone_2_L = headBone.transform.Find("Eye_tear_attach_02_L");
|
||||||
|
AttachBone_2_R = headBone.transform.Find("Eye_tear_attach_02_R");
|
||||||
|
AttachBone_3_L = headBone.transform.Find("Eye_tear_attach_03_L");
|
||||||
|
AttachBone_3_R = headBone.transform.Find("Eye_tear_attach_03_R");
|
||||||
|
|
||||||
|
TearObject_0 = tearPrefab_0;
|
||||||
|
AssetHolder0 = TearObject_0.GetComponent<AssetHolder>();
|
||||||
|
TearMaterial_0 = TearObject_0.GetComponentInChildren<SkinnedMeshRenderer>().material;
|
||||||
|
Animator_0 = TearObject_0.GetComponent<Animator>();
|
||||||
|
var clip = AssetHolder0._assetTable["default_animation"] as AnimationClip;
|
||||||
|
var controller = new AnimatorOverrideController(Animator_0.runtimeAnimatorController);
|
||||||
|
controller["anm_tear000_00"] = clip;
|
||||||
|
Animator_0.runtimeAnimatorController = controller;
|
||||||
|
|
||||||
|
TearObject_1 = tearPrefab_1;
|
||||||
|
AssetHolder1 = TearObject_1.GetComponent<AssetHolder>();
|
||||||
|
TearMaterial_1 = TearObject_1.GetComponentInChildren<SkinnedMeshRenderer>().material;
|
||||||
|
Animator_1 = TearObject_1.GetComponent<Animator>();
|
||||||
|
clip = AssetHolder1._assetTable["default_animation"] as AnimationClip;
|
||||||
|
controller = new AnimatorOverrideController(Animator_1.runtimeAnimatorController);
|
||||||
|
controller["anm_tear000_00"] = clip;
|
||||||
|
Animator_1.runtimeAnimatorController = controller;
|
||||||
|
|
||||||
|
SetWegiht(0);
|
||||||
|
SetDir(dir);
|
||||||
|
SetObject(currentObject);
|
||||||
|
|
||||||
|
intialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDir(int dir)
|
||||||
|
{
|
||||||
|
if (intialized && ((dir > 0 && CurrentDir > 0) || (dir <= 0 && CurrentDir <= 0))) return;
|
||||||
|
|
||||||
|
CurrentDir = dir;
|
||||||
|
if (dir > 0)//RightEye
|
||||||
|
{
|
||||||
|
TearObject_0.transform.position = AttachBone_3_R.position + AttachBone_3_R.forward * 0.004f;
|
||||||
|
TearObject_1.transform.position = AttachBone_2_R.position + AttachBone_2_R.forward * 0.004f;
|
||||||
|
TearObject_0.transform.localScale = new Vector3(-1, 1, 1);
|
||||||
|
TearObject_1.transform.localScale = new Vector3(-1, 1, 1);
|
||||||
|
}
|
||||||
|
else//LeftEye
|
||||||
|
{
|
||||||
|
TearObject_0.transform.position = AttachBone_3_L.position + AttachBone_3_L.forward * 0.004f;
|
||||||
|
TearObject_1.transform.position = AttachBone_2_L.position + AttachBone_2_L.forward * 0.004f;
|
||||||
|
TearObject_0.transform.localScale = new Vector3(1, 1, 1);
|
||||||
|
TearObject_1.transform.localScale = new Vector3(1, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetObject(int curObject)
|
||||||
|
{
|
||||||
|
if (intialized && ((curObject < 1 && CurrenObject < 1) || (curObject >= 1 && CurrenObject >= 1))) return;
|
||||||
|
|
||||||
|
CurrenObject = curObject;
|
||||||
|
CurrentAnimator = (curObject < 1) ? Animator_0 : Animator_1;
|
||||||
|
CurrentMaterial = (curObject < 1) ? TearMaterial_0 : TearMaterial_1;
|
||||||
|
CurrentAssetHolder = (curObject < 1) ? AssetHolder0 : AssetHolder1;
|
||||||
|
if (Weight > 0)
|
||||||
|
{
|
||||||
|
TearObject_0.SetActive(curObject < 1);
|
||||||
|
TearObject_1.SetActive(curObject >= 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetWegiht(float weight)
|
||||||
|
{
|
||||||
|
if (intialized && (weight <= 0 && Weight <= 0)) return;
|
||||||
|
|
||||||
|
Weight = weight;
|
||||||
|
if (weight <= 0)
|
||||||
|
{
|
||||||
|
TearObject_0.SetActive(false);
|
||||||
|
TearObject_1.SetActive(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TearObject_0.SetActive(CurrenObject < 1);
|
||||||
|
TearObject_1.SetActive(CurrenObject >= 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSpeed(float speed)
|
||||||
|
{
|
||||||
|
if (speed == Speed) return;
|
||||||
|
Speed = speed;
|
||||||
|
Animator_0.speed = speed;
|
||||||
|
Animator_1.speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateOffset()
|
||||||
|
{
|
||||||
|
if (Weight <= 0) return;
|
||||||
|
|
||||||
|
var time = Mathf.Repeat(CurrentAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime,1);
|
||||||
|
var width = (int)CurrentAssetHolder._assetTableValue["texture_width"];
|
||||||
|
var height = (int)CurrentAssetHolder._assetTableValue["texture_height"];
|
||||||
|
var partWidth = (int)CurrentAssetHolder._assetTableValue["texture_part_width"];
|
||||||
|
var partHeight = (int)CurrentAssetHolder._assetTableValue["texture_part_height"];
|
||||||
|
var offset = GetTextureOffset(time, width, height, partWidth, partHeight);
|
||||||
|
CurrentMaterial.SetColor("_TexScrollParam", new Color(offset.x, -offset.y, 0, Weight));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2 GetTextureOffset(float time,int w,int h,int pw ,int ph)
|
||||||
|
{
|
||||||
|
int wCount = w / pw;
|
||||||
|
int hCount = h / ph;
|
||||||
|
int index = (int)(time * (wCount * hCount));
|
||||||
|
return new Vector2((index % wCount) / (float)wCount,(index/wCount)/(float)hCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 52416b72680489b4a9a3b590b739e09a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user