本文整理匯總了C#中UnityEngine.Animation.Sample方法的典型用法代碼示例。如果您正苦於以下問題:C# Animation.Sample方法的具體用法?C# Animation.Sample怎麽用?C# Animation.Sample使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UnityEngine.Animation
的用法示例。
在下文中一共展示了Animation.Sample方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AdvanceAnimationTo
public float AdvanceAnimationTo(Animation anim, string clip, float to, float dt, float last = -1)
{
float ret = to;
AnimationState st = anim[clip];
st.enabled = true;
st.weight = 1;
if (last < 0)
{
last = st.normalizedTime;
}
ret = st.normalizedTime = Mathf.MoveTowards(last, to, dt * st.length);
anim.Sample();
st.enabled = false;
return ret;
}
示例2: OnStart
public override void OnStart(StartState state)
{
radiatedThermalPower = 0;
convectedThermalPower = 0;
current_rad_temp = 0;
directionrotate = 1;
//oldangle = 0;
last_draw_update = 0;
update_count = 0;
hasrequiredupgrade = false;
explode_counter = 0;
UpdateEnableAutomation();
if (upgradedRadiatorArea == 1)
upgradedRadiatorArea = radiatorArea * 1.7f;
Actions["DeployRadiatorAction"].guiName = Events["DeployRadiator"].guiName = "Deploy Radiator";
Actions["RetractRadiatorAction"].guiName = Events["RetractRadiator"].guiName = "Retract Radiator";
Actions["ToggleRadiatorAction"].guiName = String.Format("Toggle Radiator");
var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT);
// calculate WasteHeat Capacity
if (wasteheatPowerResource != null)
{
var ratio = Math.Min(1, Math.Max(0, wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount));
wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier;
wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio;
}
var myAttachedEngine = this.part.FindModuleImplementing<ModuleEngines>();
if (myAttachedEngine == null)
{
Fields["partMass"].guiActiveEditor = true;
Fields["upgradeTechReq"].guiActiveEditor = true;
Fields["convectiveBonus"].guiActiveEditor = true;
Fields["upgradedRadiatorTemp"].guiActiveEditor = true;
}
if (state == StartState.Editor)
{
if (hasTechsRequiredToUpgrade())
{
isupgraded = true;
hasrequiredupgrade = true;
}
return;
}
list_of_thermal_sources = vessel.FindPartModulesImplementing<IThermalSource>();
if (ResearchAndDevelopment.Instance != null)
upgradeCostStr = ResearchAndDevelopment.Instance.Science + "/" + upgradeCost.ToString("0") + " Science";
if (state == PartModule.StartState.Docked)
{
base.OnStart(state);
return;
}
// add to static list of all radiators
FNRadiator.list_of_all_radiators.Add(this);
moduleDeployableRadiator = part.FindModuleImplementing<ModuleDeployableRadiator>();
array = part.FindModelComponents<Renderer>();
deployAnim = part.FindModelAnimators (animName).FirstOrDefault ();
if (deployAnim != null)
{
deployAnim [animName].layer = 1;
if (radiatorIsEnabled)
{
deployAnim[animName].normalizedTime = 1.0f;
deployAnim[animName].enabled = true;
deployAnim.Sample();
}
}
if (!String.IsNullOrEmpty(thermalAnim))
heatStates = SetUpAnimation(thermalAnim, this.part);
if (isDeployable)
{
pivot = part.FindModelTransform ("suntransform");
original_eulers = pivot.transform.localEulerAngles;
}
else
radiatorIsEnabled = true;
if(HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
{
if(PluginHelper.hasTech(upgradeTechReq))
hasrequiredupgrade = true;
}
else
hasrequiredupgrade = true;
if (radiatorInit == false)
radiatorInit = true;
//.........這裏部分代碼省略.........
示例3: SampleAnimationFadeIn
public static void SampleAnimationFadeIn(Animation anim, string clipName, WrapMode wrap, float fadeDelay, float time)
{
AnimationState animState = anim[clipName];
animState.enabled = true;
animState.wrapMode = wrap;
animState.weight = time < fadeDelay ? time/fadeDelay : 1.0f;
animState.time = time;
anim.Sample();
animState.enabled = false;
}
示例4: SampleAnimationCrossFade
public static void SampleAnimationCrossFade(Animation anim, float fadeDelay, string prevClipName, WrapMode prevWrap, float prevTime, string clipName, WrapMode wrap, float time)
{
float weight = time < fadeDelay ? time / fadeDelay : 1.0f;
if(weight < 1.0f) {
AnimationState animPrevState = anim[prevClipName];
AnimationState animState = anim[clipName];
animPrevState.enabled = true;
animPrevState.wrapMode = prevWrap;
animPrevState.weight = 1.0f - weight;
animPrevState.time = prevTime;
animState.enabled = true;
animState.wrapMode = wrap;
animState.weight = weight;
animState.time = time;
anim.Sample();
animPrevState.enabled = false;
animState.enabled = false;
}
else {
AnimationState animState = anim[clipName];
animState.enabled = true;
animState.wrapMode = wrap;
animState.weight = weight;
animState.time = time;
anim.Sample();
animState.enabled = false;
}
}
示例5: SampleAnimation
public static void SampleAnimation(Animation anim, string clipName, WrapMode wrap, float weight, float time)
{
AnimationState animState = anim[clipName];
animState.enabled = true;
animState.wrapMode = wrap;
animState.weight = weight;
animState.time = time;
anim.Sample();
animState.enabled = false;
}
示例6: OnStart
public override void OnStart(PartModule.StartState state)
{
String[] resources_to_supply = { FNResourceManager.FNRESOURCE_MEGAJOULES, FNResourceManager.FNRESOURCE_WASTEHEAT, FNResourceManager.FNRESOURCE_THERMALPOWER };
wasteheatResource = part.Resources[FNResourceManager.FNRESOURCE_WASTEHEAT];
this.resources_to_supply = resources_to_supply;
base.OnStart(state);
if (state == StartState.Editor) { return; }
// calculate WasteHeat Capacity
partBaseWasteheat = part.mass * 1.0e+5 * wasteHeatMultiplier + (StableMaximumReactorPower * 100);
if (wasteheatResource != null)
{
var ratio = wasteheatResource.amount / wasteheatResource.maxAmount;
wasteheatResource.maxAmount = partBaseWasteheat;
wasteheatResource.amount = wasteheatResource.maxAmount * ratio;
}
if (part.FindModulesImplementing<MicrowavePowerTransmitter>().Count == 1)
{
part_transmitter = part.FindModulesImplementing<MicrowavePowerTransmitter>().First();
has_transmitter = true;
}
if (animTName != null)
{
animT = part.FindModelAnimators(animTName).FirstOrDefault();
if (animT != null)
{
animT[animTName].enabled = true;
animT[animTName].layer = 1;
animT[animTName].normalizedTime = 0f;
animT[animTName].speed = 0.001f;
animT.Sample();
}
}
if (animName != null)
anim = part.FindModelAnimators(animName).FirstOrDefault();
penaltyFreeDistance = Math.Sqrt(1 / ((microwaveAngleTan * microwaveAngleTan) / collectorArea));
this.part.force_activate();
}
示例7: PlayAnimation
/// <summary>
/// 播放動畫片段
/// </summary>
/// <param name="anim"></param>
/// <param name="name"></param>
/// <param name="dir"></param>
/// <returns></returns>
public static AnimationState PlayAnimation(Animation anim, string name, AnimationOrTween.Direction dir)
{
var state = anim[name];
if (state)
{
float speed = Mathf.Abs(state.speed);
state.speed = speed * (int)dir;
if (dir == AnimationOrTween.Direction.Reverse && state.time == 0f) state.time = state.length;
else if (dir == AnimationOrTween.Direction.Forward && state.time == state.length) state.time = 0f;
//Debug.Log(string.Format(" speed {0},dir ={1},time = {2},length={3}",state.speed,dir,state.time,state.length));
anim.Play(name);
anim.Sample();
}
return state;
}
示例8: OnStart
public override void OnStart(PartModule.StartState state) {
Actions["DeployRadiatorAction"].guiName = Events["DeployRadiator"].guiName = String.Format("Deploy Radiator");
Actions["RetractRadiatorAction"].guiName = Events["RetractRadiator"].guiName = String.Format("Retract Radiator");
Actions["ToggleRadiatorAction"].guiName = String.Format("Toggle Radiator");
if (state == StartState.Editor) {
if (hasTechsRequiredToUpgrade()) {
isupgraded = true;
hasrequiredupgrade = true;
}
return;
}
FNRadiator.list_of_radiators.Add (this);
anim = part.FindModelAnimators (animName).FirstOrDefault ();
//orig_emissive_colour = part.renderer.material.GetTexture (emissive_property_name);
if (anim != null) {
anim [animName].layer = 1;
if (radiatorIsEnabled) {
anim[animName].normalizedTime = 1.0f;
anim[animName].enabled = true;
anim.Sample();
} else {
//anim.Blend (animName, 0, 0);
}
//anim.Play ();
}
if (isDeployable) {
pivot = part.FindModelTransform ("suntransform");
original_eulers = pivot.transform.localEulerAngles;
} else {
radiatorIsEnabled = true;
}
if(HighLogic.CurrentGame.Mode == Game.Modes.CAREER) {
if(PluginHelper.hasTech(upgradeTechReq)) {
hasrequiredupgrade = true;
}
}else{
hasrequiredupgrade = true;
}
if (radiatorInit == false) {
radiatorInit = true;
}
if (!isupgraded) {
radiatorType = originalName;
} else {
radiatorType = upgradedName;
radiatorTemp = upgradedRadiatorTemp;
}
radiatorTempStr = radiatorTemp + "K";
maxQStr = maxQ + " Pa";
this.part.force_activate();
}
示例9: sample
private void sample(Animation anim, AnimationState clip, float time)
{
bool en = clip.enabled;
clip.enabled = true;
clip.normalizedTime = time;
clip.weight = 1;
anim.Sample();
clip.enabled = en;//restore previous enabled state...
}
示例10: OnStart
public override void OnStart(PartModule.StartState state)
{
_moduleDeployableRadiator = part.FindModuleImplementing<ModuleDeployableRadiator>();
radiatedThermalPower = 0;
convectedThermalPower = 0;
current_rad_temp = 0;
directionrotate = 1;
oldangle = 0;
last_draw_update = 0;
update_count = 0;
hasrequiredupgrade = false;
explode_counter = 0;
if (upgradedRadiatorArea == 1)
upgradedRadiatorArea = radiatorArea * 1.7f;
Actions["DeployRadiatorAction"].guiName = Events["DeployRadiator"].guiName = String.Format("Deploy Radiator");
Actions["RetractRadiatorAction"].guiName = Events["RetractRadiator"].guiName = String.Format("Retract Radiator");
Actions["ToggleRadiatorAction"].guiName = String.Format("Toggle Radiator");
var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT);
// calculate WasteHeat Capacity
if (wasteheatPowerResource != null)
{
var ratio = Math.Min(1, Math.Max(0, wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount));
wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier;
wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio;
}
if (state == StartState.Editor)
{
if (hasTechsRequiredToUpgrade())
{
isupgraded = true;
hasrequiredupgrade = true;
}
return;
}
FNRadiator.list_of_radiators.Add (this);
anim = part.FindModelAnimators (animName).FirstOrDefault ();
//orig_emissive_colour = part.renderer.material.GetTexture (emissive_property_name);
if (anim != null)
{
anim [animName].layer = 1;
if (radiatorIsEnabled)
{
anim[animName].normalizedTime = 1.0f;
anim[animName].enabled = true;
anim.Sample();
}
else
{
//anim.Blend (animName, 0, 0);
}
//anim.Play ();
}
if (isDeployable)
{
pivot = part.FindModelTransform ("suntransform");
original_eulers = pivot.transform.localEulerAngles;
}
else
radiatorIsEnabled = true;
if(HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
{
if(PluginHelper.hasTech(upgradeTechReq))
hasrequiredupgrade = true;
}
else
hasrequiredupgrade = true;
if (radiatorInit == false)
radiatorInit = true;
if (!isupgraded)
radiatorType = originalName;
else
{
radiatorType = upgradedName;
radiatorTemp = upgradedRadiatorTemp;
}
radiatorTempStr = radiatorTemp + "K";
this.part.force_activate();
}
示例11: OnStart
public override void OnStart(PartModule.StartState state)
{
String[] resources_to_supply = { FNResourceManager.FNRESOURCE_MEGAJOULES, FNResourceManager.FNRESOURCE_WASTEHEAT, FNResourceManager.FNRESOURCE_THERMALPOWER };
this.resources_to_supply = resources_to_supply;
base.OnStart(state);
if (state == StartState.Editor) { return; }
if (part.FindModulesImplementing<MicrowavePowerTransmitter>().Count == 1)
{
part_transmitter = part.FindModulesImplementing<MicrowavePowerTransmitter>().First();
has_transmitter = true;
}
if (animTName != null)
{
animT = part.FindModelAnimators(animTName).FirstOrDefault();
if (animT != null)
{
animT[animTName].enabled = true;
animT[animTName].layer = 1;
animT[animTName].normalizedTime = 0f;
animT[animTName].speed = 0.001f;
animT.Sample();
}
}
if (animName != null)
{
anim = part.FindModelAnimators(animName).FirstOrDefault();
}
penaltyFreeDistance = Math.Sqrt(1 / ((microwaveAngleTan * microwaveAngleTan) / collectorArea));
this.part.force_activate();
}
示例12: PlayAnimation
/// <summary>
/// 播放動畫片段
/// </summary>
/// <param name="anim"></param>
/// <param name="name"></param>
/// <param name="dir"></param>
/// <returns></returns>
public static AnimationState PlayAnimation(Animation anim, string name, AnimationDirection dir)
{
if (string.IsNullOrEmpty(name)) name = anim.clip.name;
var state = anim[name];
if (state)
{
float speed = state.speed;
if (dir == AnimationDirection.Toggle)
{
if (speed > 0 && state.time == 0 )
dir = AnimationDirection.Reverse;
else
dir = AnimationDirection.Forward;
}
if (dir == AnimationDirection.Reverse && state.time == 0f)
{
state.time = state.length;
}
else if (dir == AnimationDirection.Forward && state.time == state.length)
{
state.time = 0f;
}
state.speed = Mathf.Abs(speed) * (int)dir;
anim.Play(name);
anim.Sample();
}
return state;
}
示例13: BakeSkinnedMesh
private void BakeSkinnedMesh(Animation animation, SkinnedMeshRenderer skinnedMeshRenderer)
{
int clipIndex = 0;
foreach (AnimationState clipState in animation)
{
//Prep animation clip for sampling
var curClip = this.AnimationClipsToBake[clipIndex] = animation.GetClip(clipState.name);
animation.Play(clipState.name, PlayMode.StopAll);
clipState.time = 0;
clipState.wrapMode = WrapMode.Clamp;
//Calculate number of meshes to bake in this clip sequence based on the clip's sampling framerate
uint numberOfFrames = (uint)Mathf.RoundToInt(curClip.frameRate * curClip.length);
var curBakedMeshSequence = this.BakedClips[clipIndex] = new MeshSequence(numberOfFrames);
for (uint frameIndex = 0; frameIndex < numberOfFrames; frameIndex++)
{
//Bake sequence of meshes
var curMeshFrame = curBakedMeshSequence[frameIndex] = new Mesh();
curMeshFrame.name = string.Format(@"{0}_Baked_{1}_{2}", this.name, clipIndex, frameIndex);
animation.Sample();
skinnedMeshRenderer.BakeMesh(curMeshFrame);
clipState.time += (1.0f / curClip.frameRate);
}
animation.Stop();
clipIndex++;
}
}
示例14: OnStart
public override void OnStart(PartModule.StartState state)
{
if (state == StartState.Editor) { return; }
generators = vessel.FindPartModulesImplementing<FNGenerator>();
receivers = vessel.FindPartModulesImplementing<MicrowavePowerReceiver>();
panels = vessel.FindPartModulesImplementing<ModuleDeployableSolarPanel>();
if (part.FindModulesImplementing<MicrowavePowerReceiver>().Count == 1)
{
part_receiver = part.FindModulesImplementing<MicrowavePowerReceiver>().First();
has_receiver = true;
}
anim = part.FindModelAnimators(animName).FirstOrDefault();
if (anim != null)
{
anim[animName].layer = 1;
if (IsEnabled)
{
anim[animName].normalizedTime = 1f;
anim[animName].enabled = true;
anim.Sample();
}
}
this.part.force_activate();
}