本文整理汇总了C#中UnityEngine.Animation.Play方法的典型用法代码示例。如果您正苦于以下问题:C# Animation.Play方法的具体用法?C# Animation.Play怎么用?C# Animation.Play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Animation
的用法示例。
在下文中一共展示了Animation.Play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStart
public override void OnStart(PartModule.StartState state)
{
DragManager = part.gameObject.GetComponent<DragManager>();
if (DragManager == null) {
DragManager = part.gameObject.AddComponent<DragManager>();
DragManager.SetPart(part);
}
anim = part.FindModelAnimators(AnimationName)[0];
animState = anim[AnimationName];
animState.wrapMode = WrapMode.Clamp;
if (FixAnimLayers) {
int i = 0;
foreach (AnimationState s in anim)
s.layer = i++;
}
animState.normalizedSpeed = 0;
if (engaged) {
animState.normalizedTime = Drag / 100;
spoilerState = ModuleLandingGear.GearStates.DEPLOYED;
}
else {
animState.normalizedTime = 0;
spoilerState = ModuleLandingGear.GearStates.RETRACTED;
}
anim.Play(AnimationName);
}
示例2: Start
// ============================================================================================================
public void Start()
{
ani = GetComponent<Animation>();
chara = GetComponent<Chara2_Base>();
// init idle ani
if (string.IsNullOrEmpty(idleClip)) idleClip = null; // set to null for faster if() checks
if (idleClip != null)
{
ani[idleClip].speed = idlePlaySpeed;
ani[idleClip].wrapMode = WrapMode.Loop;
ani.Play(idleClip);
}
// sorted so that lower speedDetect is checked first
movementAnimations.Sort((a, b) => { return a.maxSpeedDetect.CompareTo(b.maxSpeedDetect); });
// init movement anis
for (int i = 0; i < movementAnimations.Count; i++)
{
if (!string.IsNullOrEmpty(movementAnimations[i].clipName))
{
ani[movementAnimations[i].clipName].speed = movementAnimations[i].playSpeed;
ani[movementAnimations[i].clipName].wrapMode = WrapMode.Loop;
}
else movementAnimations[i] = null; // set to null for faster if() checks
}
// init antics
_anticsOn = (UniRPGGlobal.Instance.state != UniRPGGlobal.State.InMainMenu);
anticsTimer = anticsWaitTimeMin;
}
示例3: OnStart
public override void OnStart(PartModule.StartState state) {
if (state == StartState.Editor) { return; }
this.part.force_activate();
anim = part.FindModelAnimators (animName).FirstOrDefault ();
if (anim != null) {
anim [animName].layer = 1;
if (!IsEnabled) {
anim [animName].normalizedTime = 1f;
anim [animName].speed = -1f;
} else {
anim [animName].normalizedTime = 0f;
anim [animName].speed = 1f;
}
anim.Play ();
}
}
示例4: OnStart
public override void OnStart(PartModule.StartState state) {
Actions["ActivateTransmitterAction"].guiName = Events["ActivateTransmitter"].guiName = String.Format("Activate Transmitter");
Actions["DeactivateTransmitterAction"].guiName = Events["DeactivateTransmitter"].guiName = String.Format("Deactivate Transmitter");
if (state == StartState.Editor) { return; }
this.part.force_activate();
anim = part.FindModelAnimators (animName).FirstOrDefault ();
if (anim != null) {
anim [animName].layer = 1;
if (!IsEnabled) {
anim [animName].normalizedTime = 1f;
anim [animName].speed = -1f;
} else {
anim [animName].normalizedTime = 0f;
anim [animName].speed = 1f;
}
anim.Play ();
}
List<Part> vesselparts = vessel.parts;
for (int i = 0; i < vesselparts.Count; ++i) {
Part cPart = vesselparts.ElementAt(i);
PartModuleList pml = cPart.Modules;
for (int j = 0; j < pml.Count; ++j) {
var curSolarPan = pml.GetModule(j) as ModuleDeployableSolarPanel;
if (curSolarPan != null) {
//curSolarPan.powerCurve = PluginHelper.getSatFloatCurve();
}
}
}
}
示例5: thawCryopodWindow
private void thawCryopodWindow(int seatIndx, float speed)
{
setCryopodWindowOpaque(seatIndx);
string windowname = "Animated-Cryopod-" + (seatIndx + 1).ToString() + "-Window";
_windowAnimation = this.part.internalModel.FindModelComponent<Animation>(windowname);
if (_windowAnimation == null)
{
this.Log_Debug("Why can't I find the window animation?");
}
else
{
_windowAnimation["CryopodWindowOpen"].speed = speed;
_windowAnimation.Play("CryopodWindowOpen");
}
}
示例6: Start
public void Start()
{
thisTransform = transform;
thisAnimation = GetComponent<Animation>();
gameManager = GameManager.instance;
thisTransform.position = spawnPosition;
thisTransform.eulerAngles = spawnRotation;
platformLayer = (1 << LayerMask.NameToLayer("Platform")) | (1 << LayerMask.NameToLayer("PlatformJump")) | (1 << LayerMask.NameToLayer("Floor"));
// setup the animation wrap modes
thisAnimation[idleAnimationName].wrapMode = WrapMode.Loop;
thisAnimation[runAnimationName].wrapMode = WrapMode.Loop;
thisAnimation[attackAnimationName].wrapMode = WrapMode.Once;
thisAnimation.Play(idleAnimationName);
GameManager.instance.OnStartGame += StartGame;
}
示例7: OnStart
public override void OnStart(PartModule.StartState state)
{
print("[KSP Interstellar] Generator OnStart Begin " + startcount);
String[] resources_to_supply = { FNResourceManager.FNRESOURCE_MEGAJOULES, FNResourceManager.FNRESOURCE_WASTEHEAT };
this.resources_to_supply = resources_to_supply;
if (state == PartModule.StartState.Docked)
{
base.OnStart(state);
return;
}
// calculate WasteHeat Capacity
var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT);
if (wasteheatPowerResource != null)
{
var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount;
wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier;
wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio;
}
previousTimeWarp = TimeWarp.fixedDeltaTime - 1.0e-6f;
megajouleResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_MEGAJOULES);
base.OnStart(state);
generatorType = originalName;
Fields["maxChargedPower"].guiActive = chargedParticleMode;
Fields["maxThermalPower"].guiActive = !chargedParticleMode;
if (state == StartState.Editor)
{
if (this.HasTechsRequiredToUpgrade())
{
isupgraded = true;
hasrequiredupgrade = true;
upgradePartModule();
}
part.OnEditorAttach += OnEditorAttach;
return;
}
if (this.HasTechsRequiredToUpgrade())
hasrequiredupgrade = true;
this.part.force_activate();
anim = part.FindModelAnimators(animName).FirstOrDefault();
if (anim != null)
{
anim[animName].layer = 1;
if (!IsEnabled)
{
anim[animName].normalizedTime = 1f;
anim[animName].speed = -1f;
}
else
{
anim[animName].normalizedTime = 0f;
anim[animName].speed = 1f;
}
anim.Play();
}
if (generatorInit == false)
{
generatorInit = true;
IsEnabled = true;
}
if (isupgraded)
upgradePartModule();
FindAttachedThermalSource();
UpdateHeatExchangedThrustDivisor();
print("[KSP Interstellar] Generator OnStart Finished");
}
示例8: VariableAnimationSet
public VariableAnimationSet(ConfigNode node, InternalProp thisProp)
{
part = thisProp.part;
if (!node.HasData)
{
throw new ArgumentException("No data?!");
}
comp = RasterPropMonitorComputer.Instantiate(thisProp);
string[] tokens = { };
if (node.HasValue("scale"))
{
tokens = node.GetValue("scale").Split(',');
}
if (tokens.Length != 2)
{
throw new ArgumentException("Could not parse 'scale' parameter.");
}
if (node.HasValue("variableName"))
{
string variableName;
variableName = node.GetValue("variableName").Trim();
scaleEnds[2] = new VariableOrNumber(variableName, this);
}
else if (node.HasValue("stateMethod"))
{
Func<bool> stateFunction = (Func<bool>)comp.GetMethod(node.GetValue("stateMethod").Trim(), thisProp, typeof(Func<bool>));
if (stateFunction != null)
{
scaleEnds[2] = new VariableOrNumber(stateFunction, this);
}
else
{
throw new ArgumentException("Unrecognized stateMethod");
}
}
else
{
throw new ArgumentException("Missing variable name.");
}
scaleEnds[0] = new VariableOrNumber(tokens[0], this);
scaleEnds[1] = new VariableOrNumber(tokens[1], this);
// That takes care of the scale, now what to do about that scale:
if (node.HasValue("reverse"))
{
if (!bool.TryParse(node.GetValue("reverse"), out reverse))
{
throw new ArgumentException("So is 'reverse' true or false?");
}
}
if (node.HasValue("animationName"))
{
animationName = node.GetValue("animationName");
if (node.HasValue("animationSpeed"))
{
animationSpeed = float.Parse(node.GetValue("animationSpeed"));
if (reverse)
{
animationSpeed = -animationSpeed;
}
}
else
{
animationSpeed = 0.0f;
}
Animation[] anims = node.HasValue("animateExterior") ? thisProp.part.FindModelAnimators(animationName) : thisProp.FindModelAnimators(animationName);
if (anims.Length > 0)
{
onAnim = anims[0];
onAnim.enabled = true;
onAnim[animationName].speed = 0;
onAnim[animationName].normalizedTime = reverse ? 1f : 0f;
looping = node.HasValue("loopingAnimation");
if (looping)
{
onAnim[animationName].wrapMode = WrapMode.Loop;
onAnim.wrapMode = WrapMode.Loop;
onAnim[animationName].speed = animationSpeed;
mode = Mode.LoopingAnimation;
}
else
{
onAnim[animationName].wrapMode = WrapMode.Once;
mode = Mode.Animation;
}
onAnim.Play();
alwaysActive = node.HasValue("animateExterior");
}
else
{
//.........这里部分代码省略.........
示例9: openCryopod
//only called for animated internal parts
private void openCryopod(int seatIndx, float speed)
{
string podname = "Animated-Cryopod-" + (seatIndx + 1);
try
{
_animation = part.internalModel.FindModelComponent<Animation>(podname);
if (_animation != null)
{
if (cryopodstateclosed[seatIndx])
{
_animation["Open"].speed = speed;
_animation.Play("Open");
cryopodstateclosed[seatIndx] = false;
savecryopodstatepersistent();
}
}
else
Utilities.Log_Debug("animation not found");
}
catch (Exception ex)
{
Debug.Log("Unable to find animation in internal model for this part called " + podname);
Debug.Log("Err: " + ex);
}
}
示例10: OnStart
public override void OnStart(PartModule.StartState state)
{
Actions["ActivateReceiverAction"].guiName = Events["ActivateReceiver"].guiName = String.Format("Activate Receiver");
Actions["DisableReceiverAction"].guiName = Events["DisableReceiver"].guiName = String.Format("Disable Receiver");
Actions["ToggleReceiverAction"].guiName = String.Format("Toggle Receiver");
base.OnStart (state);
if (state == StartState.Editor) { return; }
this.part.force_activate();
anim = part.FindModelAnimators (animName).FirstOrDefault ();
if (anim != null) {
anim [animName].layer = 1;
if (connectedsatsf > 0 || connectedrelaysf > 0) {
anim [animName].normalizedTime = 1f;
anim [animName].speed = -1f;
} else {
anim [animName].normalizedTime = 0f;
anim [animName].speed = 1f;
}
anim.Play ();
}
if (mycount == -1) {
mycount = dishcount;
dishcount++;
}
}
示例11: PlayLoopAnimation
private void PlayLoopAnimation(Animation StartAnimation, string startAnimationName, int speed, bool instant)
{
if (startAnimationName != "")
{
// //print(StartAnimation[startAnimationName].time.ToString() + " " + loopPoint.ToString());
if (StartAnimation[startAnimationName].time >= StartAnimation[startAnimationName].length || StartAnimation.isPlaying == false)
{
StartAnimation[startAnimationName].time = loopPoint;
////print(StartAnimation[startAnimationName].time.ToString() + " " + loopPoint.ToString());
if (instant)
StartAnimation[startAnimationName].speed = 999999 * speed;
StartAnimation[startAnimationName].speed = speed;
StartAnimation[startAnimationName].wrapMode = WrapMode.Default;
StartAnimation.Play(startAnimationName);
}
}
}
示例12: PlayStartAnimation
private void PlayStartAnimation(Animation StartAnimation, string startAnimationName, int speed, bool instant)
{
if (startAnimationName != "")
{
if (speed < 0)
{
StartAnimation[startAnimationName].time = StartAnimation[startAnimationName].length;
if (loopPoint != 0)
StartAnimation[startAnimationName].time = loopPoint;
}
if (instant)
StartAnimation[startAnimationName].speed = 999999 * speed;
StartAnimation[startAnimationName].wrapMode = WrapMode.Default;
StartAnimation[startAnimationName].speed = speed;
StartAnimation.Play(startAnimationName);
}
}
示例13: 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].speed = -1f;
}
else
{
anim[animName].normalizedTime = 0f;
anim[animName].speed = 1f;
}
anim.Play();
}
this.part.force_activate();
// Debug.Log("[KSPI] - MicrowavePowerTransmitter - Looking for externalPowerSources");
// foreach (Part vesselpart in vessel.Parts)
// {
// if (vesselpart.partName == "reactor-25")
// {
// externalPowerSources.Add(new ExternalPowerSourePartModule() { Name = "reactor-25", Power = 2 });
// Debug.Log("[KSPI] - MicrowavePowerTransmitter - found " + vesselpart.partInfo.title);
// }
//}
}
示例14: OnStart
//----------------methods-----------------
public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);
//find the animation
anim = part.FindModelAnimators(animationName).FirstOrDefault();
//find the dependent module
dependent = (PlanetaryModule)this.part.GetComponent("PlanetaryModule");
if (anim != null) //Only Init when an animation is available
{
if (!hasBeenInitialized) // Run Only on first launch
{
nextIsReverse = false;
animationTime = 0f;
anim[animationName].normalizedTime = 0f;
hasBeenInitialized = true;
}
// make sure you stay in your place on launch, and don't start going in the wrong direction if deployed/retracted
if (nextIsReverse)
{
anim[animationName].speed = 1f;
if (animationTime == 0f)
{
animationTime = 1f;
}
if (animationTime == 1f)
{
lightStatus = "On";
}
else
{
lightStatus = "Turning on";
}
}
else
{
if (animationTime == 0f)
{
lightStatus = "Off";
}
else
{
lightStatus = "Turning off";
}
anim[animationName].speed = -1f;
}
//set up animation state according to persistent values
anim[animationName].layer = layer;
anim.Play(animationName);
anim[animationName].normalizedTime = animationTime;
//Settings for the GUI
if (nextIsReverse)
{
Events["toggleAnimation"].guiName = endEventGUIName;
}
else
{
Events["toggleAnimation"].guiName = startEventGUIName;
}
//check whether the element can be active or not
bool bShowGUI = true;
if (dependent != null)
{
bShowGUI = dependent.status.Equals("Deployed");
}
Events["toggleAnimation"].guiActiveEditor = availableInEditor;
Events["toggleAnimation"].guiActiveUnfocused = availableInEVA && bShowGUI;
Events["toggleAnimation"].guiActive = availableInVessel && bShowGUI;
Events["toggleAnimation"].unfocusedRange = EVArange;
}
else //When the animation can not be found deactivate it in the GUI
{
Events["toggleAnimation"].guiActiveEditor = false;
Events["toggleAnimation"].guiActive = false;
Events["toggleAnimation"].guiActiveUnfocused = false;
Debug.Log("KBILightAnimation: Animation not found: " + animationName);
}
}
示例15: Start
void Start()
{
m_controller = this.GetComponentInChildren<CharacterController>();
m_curState = AnimStates.Idle;
m_animComponent = this.gameObject.GetComponentInChildren<Animation>();
m_isDead = false;
m_isSitting = false;
for (int i = 0; i < (int)AnimationType.DEFAULT; i++)
{
m_animComponent.AddClip(characterAnimations[i], ((AnimationType)i).ToString());
}
m_animComponent.Play(characterAnimations[(int)AnimationType.Idle].name);
m_animComponent.wrapMode = WrapMode.Loop;
m_attackType = AnimAttackType.None;
m_turnDir = TurningType.None;
}