本文整理汇总了C#中UMAData类的典型用法代码示例。如果您正苦于以下问题:C# UMAData类的具体用法?C# UMAData怎么用?C# UMAData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UMAData类属于命名空间,在下文中一共展示了UMAData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateUMA
void GenerateUMA()
{
GameObject myUMA = new GameObject("MyUMA");
avatar = myUMA.AddComponent<UMADynamicAvatar>();
avatar.Initialize();
umaData = avatar.umaData;
avatar.umaGenerator = generator;
umaData.umaGenerator = generator;
umaData.umaRecipe = new UMAData.UMARecipe();
umaData.umaRecipe.slotDataList = new SlotData[NUM_SLOTS];
umaDna = new UMADnaHumanoid();
umaTutorialDna = new UMADnaTutorial();
umaData.umaRecipe.AddDna(umaDna);
umaData.umaRecipe.AddDna(umaTutorialDna);
CreateMale();
avatar.animationController = animController;
avatar.UpdateNewRace();
myUMA.transform.parent = this.gameObject.transform;
myUMA.transform.localPosition = Vector3.zero;
myUMA.transform.localRotation = Quaternion.identity;
}
示例2: OnDnaApplied
public void OnDnaApplied(UMAData umaData)
{
var umaDna = umaData.GetDna<UMADnaHumanoid>();
if (umaDna == null)
{
Debug.LogError("Failed to add Capsule Collider to: " + umaData.name);
return;
}
var rigid = umaData.gameObject.GetComponent<Rigidbody>();
if (rigid == null)
{
rigid = umaData.gameObject.AddComponent<Rigidbody>();
}
rigid.constraints = RigidbodyConstraints.FreezeRotation;
rigid.mass = umaData.characterMass;
var capsule = umaData.gameObject.GetComponent<CapsuleCollider>();
if (capsule == null)
{
capsule = umaData.gameObject.AddComponent<CapsuleCollider>();
}
capsule.radius = umaData.characterRadius;
capsule.height = umaData.characterHeight;
capsule.center = new Vector3(0, capsule.height * 0.5f - 0.04f, 0);
}
示例3: EnsureUMADataSetup
protected void EnsureUMADataSetup(UMAData umaData)
{
if (umaData.umaRoot == null)
{
GameObject newRoot = new GameObject("Root");
newRoot.transform.parent = umaData.transform;
newRoot.transform.localPosition = Vector3.zero;
newRoot.transform.localRotation = Quaternion.Euler(270f, 0, 0f);
umaData.umaRoot = newRoot;
GameObject newGlobal = new GameObject("Global");
newGlobal.transform.parent = newRoot.transform;
newGlobal.transform.localPosition = Vector3.zero;
newGlobal.transform.localRotation = Quaternion.Euler(90f, 90f, 0f);
umaData.skeleton = new UMASkeleton(newGlobal.transform);
var newRenderer = umaData.umaRoot.AddComponent<SkinnedMeshRenderer>();
newRenderer.rootBone = newGlobal.transform;
umaData.myRenderer = newRenderer;
umaData.myRenderer.enabled = false;
umaData.myRenderer.sharedMesh = new Mesh();
}
else
{
umaData.CleanMesh(false);
}
}
示例4: Initialize
public void Initialize()
{
blinkDelay = Random.Range(minBlinkDelay, maxBlinkDelay);
if (umaData == null)
{
// Find the UMAData, which could be up or down the hierarchy
umaData = gameObject.GetComponentInChildren<UMAData>();
if (umaData == null)
{
#if UNITY_4_3
umaData = transform.root.GetComponentInChildren<UMAData>();
#else
umaData = gameObject.GetComponentInParent<UMAData>();
#endif
}
if (umaData == null)
{
Debug.LogError("Couldn't locate UMAData component");
}
}
if ((expressionSet != null) && (umaData != null) && (umaData.skeleton != null))
{
if (umaData.animator != null)
{
Transform jaw = umaData.animator.GetBoneTransform(HumanBodyBones.Jaw);
if (jaw != null)
jawHash = UMAUtils.StringToHash(jaw.name);
}
initialized = true;
}
}
示例5: RandomizeDNA
/// <summary>
/// Uniformly randomizes each value in the DNA.
/// </summary>
/// <param name="data">UMA data.</param>
public void RandomizeDNA(UMAData data)
{
if (dnaConverter == null)
return;
UMADnaBase dna = data.GetDna(dnaConverter.DNAType);
if (dna == null)
return;
int entryCount = dna.Count;
if (means.Length != entryCount)
{
Debug.LogWarning("Range settings out of sync with DNA, cannot apply!");
return;
}
if ((values == null) || (values.Length != entryCount))
values = new float[entryCount];
for (int i = 0; i < entryCount; i++)
{
values[i] = means[i] + (Random.value - 0.5f) * spreads[i];
}
dna.Values = values;
}
示例6: addDirtyUMA
/// <inheritdoc/>
public override void addDirtyUMA(UMAData umaToAdd)
{
if (umaToAdd)
{
umaDirtyList.Add(umaToAdd);
}
}
示例7: HandleDirtyUpdate
public virtual bool HandleDirtyUpdate(UMAData data)
{
if (data == null)
return true;
if (umaData != data)
{
umaData = data;
if (!umaData.Validate())
return true;
if (meshCombiner != null)
{
meshCombiner.Preprocess(umaData);
}
umaData.FireCharacterBegunEvents();
}
if (umaData.isTextureDirty)
{
if (activeGeneratorCoroutine == null)
{
activeGeneratorCoroutine = umaGeneratorCoroutine;
TextureProcessBaseCoroutine textureProcessCoroutine;
textureProcessCoroutine = new TextureProcessPROCoroutine();
textureProcessCoroutine.Prepare(data, this);
activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine, !umaData.isMeshDirty);
}
bool workDone = umaGeneratorCoroutine.Work();
if (workDone)
{
activeGeneratorCoroutine = null;
umaData.isTextureDirty = false;
umaData.isAtlasDirty = true;
}
if (!workDone || !fastGeneration || umaData.isMeshDirty)
return false;
}
if (umaData.isMeshDirty)
{
UpdateUMAMesh(umaData.isAtlasDirty);
umaData.isAtlasDirty = false;
umaData.isMeshDirty = false;
if (!fastGeneration)
return false;
}
if (umaData.isShapeDirty)
{
UpdateUMABody(umaData);
umaData.isShapeDirty = false;
}
UMAReady();
return true;
}
示例8: RandomizeDNAGaussian
/// <summary>
/// Randomizes each value in the DNA using a Gaussian distribution.
/// </summary>
/// <param name="data">UMA data.</param>
public void RandomizeDNAGaussian(UMAData data)
{
if (dnaConverter == null)
return;
UMADnaBase dna = data.GetDna(dnaConverter.DNAType);
if (dna == null)
return;
int entryCount = dna.Count;
if (means.Length != entryCount)
{
Debug.LogWarning("Range settings out of sync with DNA, cannot apply!");
return;
}
if (values == null)
values = new float[entryCount];
for (int i = 0; i < entryCount; i++)
{
values[i] = UMAUtils.GaussianRandom(means[i], deviations[i]);
}
dna.Values = values;
}
示例9: OnDnaApplied
public void OnDnaApplied(UMAData umaData)
{
if (!hashesFound)
{
leftHandHash = UMAUtils.StringToHash("LeftHand");
rightHandHash = UMAUtils.StringToHash("RightHand");
leftTwistHash = UMAUtils.StringToHash("LeftForeArmTwist");
rightTwistHash = UMAUtils.StringToHash("RightForeArmTwist");
hashesFound = true;
}
GameObject leftHand = umaData.GetBoneGameObject(leftHandHash);
GameObject rightHand = umaData.GetBoneGameObject(rightHandHash);
GameObject leftTwist = umaData.GetBoneGameObject(leftTwistHash);
GameObject rightTwist = umaData.GetBoneGameObject(rightTwistHash);
if ((leftHand == null) || (rightHand == null) || (leftTwist == null) || (rightTwist == null))
{
Debug.LogError("Failed to add Forearm Twist to: " + umaData.name);
return;
}
var twist = umaData.umaRoot.AddComponent<TwistBones>();
twist.twistValue = 0.5f;
twist.twistBone = new Transform[] {leftTwist.transform, rightTwist.transform};
twist.refBone = new Transform[] {leftHand.transform, rightHand.transform};
}
示例10: characterCreated
public void characterCreated(UMAData umaCreated)
{
head = umaCreated.GetBoneGameObject("Head");
MoveCamera();
player = gameObject.GetComponentInChildren<UMAExpressionPlayer>();
if (player == null)
{
Animator umaAnimator = GetComponentInChildren<Animator>();
if (umaAnimator != null)
{
player = umaAnimator.gameObject.AddComponent<UMAExpressionPlayer>();
player.overrideMecanimNeck = true;
player.overrideMecanimHead = true;
player.overrideMecanimJaw = true;
player.overrideMecanimEyes = true;
}
#if !UNITY_4_3
umaAnimator.Rebind();
#endif
}
if (player != null)
{
if (expressionSet != null)
{
player.expressionSet = expressionSet;
}
player.Initialize();
guiValues = new float[UMAExpressionPlayer.PoseCount];
}
}
示例11: Initialize
public void Initialize()
{
if (context == null)
{
context = UMAContext.FindInstance();
}
if (umaData == null)
{
umaData = GetComponent<UMAData>();
if (umaData == null)
{
umaData = gameObject.AddComponent<UMAData>();
if (umaGenerator != null && !umaGenerator.gameObject.activeInHierarchy)
{
Debug.LogError("Invalid UMA Generator on Avatar.", gameObject);
Debug.LogError("UMA generators must be active scene objects!", umaGenerator.gameObject);
umaGenerator = null;
}
}
}
if (umaGenerator != null)
{
umaData.umaGenerator = umaGenerator;
}
if (CharacterCreated != null) umaData.CharacterCreated = CharacterCreated;
if (CharacterDestroyed != null) umaData.CharacterDestroyed = CharacterDestroyed;
if (CharacterUpdated != null) umaData.CharacterUpdated = CharacterUpdated;
}
示例12: CreateAvatar
public static Avatar CreateAvatar(UMAData umaData, UmaTPose umaTPose)
{
umaTPose.DeSerialize();
HumanDescription description = CreateHumanDescription(umaData, umaTPose);
//DebugLogHumanAvatar(umaData.umaRoot, description);
Avatar res = AvatarBuilder.BuildHumanAvatar(umaData.umaRoot, description);
return res;
}
示例13: SetupModule
public void SetupModule(UMAData.MaterialFragment source, int textureType)
{
textureMergeRects[textureMergeRectCount].rect = source.atlasRegion;
textureMergeRects[textureMergeRectCount].rect.y = height - textureMergeRects[textureMergeRectCount].rect.y - textureMergeRects[textureMergeRectCount].rect.height;
atlasRect = textureMergeRects[textureMergeRectCount].rect;
SetupMaterial(ref textureMergeRects[textureMergeRectCount], source, textureType);
textureMergeRectCount++;
}
示例14: OnCharacterBegun
public void OnCharacterBegun(UMAData umaData)
{
var expressionPlayer = umaData.GetComponent<UMAExpressionPlayer>();
if (expressionPlayer != null)
{
expressionPlayer.SlotUpdateVsCharacterUpdate++;
}
}
示例15: SetupMaterial
private void SetupMaterial(ref TextureMergeRect textureMergeRect, UMAData.MaterialFragment source, int textureType)
{
textureMergeRect.tex = source.baseTexture[textureType];
textureMergeRect.mat.shader = (textureType == 1)? normalShader : diffuseShader;
textureMergeRect.mat.SetTexture("_MainTex", source.baseTexture[textureType]);
textureMergeRect.mat.SetTexture("_ExtraTex", source.baseTexture[0]);
textureMergeRect.mat.SetColor("_Color", source.GetMultiplier(0, textureType));
textureMergeRect.mat.SetColor("_AdditiveColor", source.GetAdditive(0, textureType));
}