Skip to content

Commit 546061c

Browse files
committed
disable animator, when clip playing
1 parent 6a87408 commit 546061c

File tree

4 files changed

+433
-6
lines changed

4 files changed

+433
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,45 @@
11
using System;
2+
using UnityEngine;
23
using UnityEngine.Playables;
34

45
namespace Bg.WaypointSystemForTimeline {
56
[Serializable]
67
public class WaypointTimelinePlayableBehaviour : PlayableBehaviour {
8+
// is stop animator controller when clip in
9+
[Tooltip("If GameObject has animator component enabled, waypoint system dose not work.")]
10+
[SerializeField] private bool _isStopAnimator = true;
11+
12+
private WaypointComponent _wayPointComponent;
13+
private Animator _animator;
14+
15+
public override void OnBehaviourPause (Playable playable, FrameData info) {
16+
EnableAnimator(true);
17+
}
18+
19+
public override void OnGraphStop (Playable playable) {
20+
EnableAnimator(true);
21+
}
22+
23+
public override void OnBehaviourPlay(Playable playable, FrameData info) {
24+
EnableAnimator(false);
25+
}
26+
727
public override void ProcessFrame(Playable playable, FrameData info, object playerData) {
828
if (playerData == null) {
929
return;
1030
}
1131

12-
var wayPointsComponent = playerData as WaypointComponent;
32+
_wayPointComponent = playerData as WaypointComponent;
33+
_animator = _wayPointComponent.GetComponent<Animator>();
34+
EnableAnimator(false);
1335

1436
double t = playable.GetTime() / playable.GetDuration();
15-
wayPointsComponent.SetPosition((float)t);
37+
_wayPointComponent.SetPosition((float)t);
38+
}
39+
40+
private void EnableAnimator(bool isEnable) {
41+
if (!_isStopAnimator || _animator == null) return;
42+
_animator.enabled = isEnable;
1643
}
1744
}
1845
}

Assets/Bg/WaypointSystemForTimeline/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.bg.waypointystemfortimeline",
33
"displayName": "WaypointSystemForTimeline",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"author": {
66
"name": "KyoheiOkawa"
77
}

Assets/Bg/WaypointSystemForTimelineSample/Basic/Basic.unity

+34-3
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1}
41+
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
4545
m_ObjectHideFlags: 0
46-
serializedVersion: 11
46+
serializedVersion: 12
4747
m_GIWorkflowMode: 1
4848
m_GISettings:
4949
serializedVersion: 2
@@ -98,7 +98,7 @@ LightmapSettings:
9898
m_TrainingDataDestination: TrainingData
9999
m_LightProbeSampleCountMultiplier: 4
100100
m_LightingDataAsset: {fileID: 0}
101-
m_UseShadowmask: 1
101+
m_LightingSettings: {fileID: 0}
102102
--- !u!196 &4
103103
NavMeshSettings:
104104
serializedVersion: 2
@@ -118,6 +118,8 @@ NavMeshSettings:
118118
manualTileSize: 0
119119
tileSize: 256
120120
accuratePlacement: 0
121+
maxJobWorkers: 0
122+
preserveTilesOutsideBounds: 0
121123
debug:
122124
m_Flags: 0
123125
m_NavMeshData: {fileID: 0}
@@ -256,6 +258,7 @@ Light:
256258
m_UseColorTemperature: 0
257259
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
258260
m_UseBoundingSphereOverride: 0
261+
m_UseViewFrustumForShadowCasterCull: 1
259262
m_ShadowRadius: 0
260263
m_ShadowAngle: 0
261264
--- !u!4 &643984079
@@ -319,6 +322,7 @@ MeshRenderer:
319322
m_LightProbeUsage: 1
320323
m_ReflectionProbeUsage: 1
321324
m_RayTracingMode: 2
325+
m_RayTraceProcedural: 0
322326
m_RenderingLayerMask: 1
323327
m_RendererPriority: 0
324328
m_Materials:
@@ -343,6 +347,7 @@ MeshRenderer:
343347
m_SortingLayerID: 0
344348
m_SortingLayer: 0
345349
m_SortingOrder: 0
350+
m_AdditionalVertexStreams: {fileID: 0}
346351
--- !u!33 &908891472
347352
MeshFilter:
348353
m_ObjectHideFlags: 0
@@ -375,6 +380,7 @@ GameObject:
375380
m_Component:
376381
- component: {fileID: 1000423089}
377382
- component: {fileID: 1000423088}
383+
- component: {fileID: 1000423090}
378384
m_Layer: 0
379385
m_Name: LookForwardWaypoint
380386
m_TagString: Untagged
@@ -428,6 +434,25 @@ Transform:
428434
m_Father: {fileID: 0}
429435
m_RootOrder: 4
430436
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
437+
--- !u!95 &1000423090
438+
Animator:
439+
serializedVersion: 3
440+
m_ObjectHideFlags: 0
441+
m_CorrespondingSourceObject: {fileID: 0}
442+
m_PrefabInstance: {fileID: 0}
443+
m_PrefabAsset: {fileID: 0}
444+
m_GameObject: {fileID: 1000423087}
445+
m_Enabled: 1
446+
m_Avatar: {fileID: 0}
447+
m_Controller: {fileID: 0}
448+
m_CullingMode: 0
449+
m_UpdateMode: 0
450+
m_ApplyRootMotion: 0
451+
m_LinearVelocityBlending: 0
452+
m_WarningMessage:
453+
m_HasTransformHierarchy: 1
454+
m_AllowConstantClipSamplingOptimization: 1
455+
m_KeepAnimatorControllerStateOnDisable: 0
431456
--- !u!1 &1138514637
432457
GameObject:
433458
m_ObjectHideFlags: 0
@@ -572,6 +597,7 @@ MeshRenderer:
572597
m_LightProbeUsage: 1
573598
m_ReflectionProbeUsage: 1
574599
m_RayTracingMode: 2
600+
m_RayTraceProcedural: 0
575601
m_RenderingLayerMask: 1
576602
m_RendererPriority: 0
577603
m_Materials:
@@ -596,6 +622,7 @@ MeshRenderer:
596622
m_SortingLayerID: 0
597623
m_SortingLayer: 0
598624
m_SortingOrder: 0
625+
m_AdditionalVertexStreams: {fileID: 0}
599626
--- !u!33 &1297932810
600627
MeshFilter:
601628
m_ObjectHideFlags: 0
@@ -660,6 +687,8 @@ PlayableDirector:
660687
value: {fileID: 441310730}
661688
- key: {fileID: -979716376006852858, guid: 33a9b07e5eb714ba7b3ca878fa81964e, type: 2}
662689
value: {fileID: 1000423088}
690+
- key: {fileID: 2878600430250776528, guid: 33a9b07e5eb714ba7b3ca878fa81964e, type: 2}
691+
value: {fileID: 1000423090}
663692
m_ExposedReferences:
664693
m_References: []
665694
--- !u!4 &1387083686
@@ -723,6 +752,7 @@ MeshRenderer:
723752
m_LightProbeUsage: 1
724753
m_ReflectionProbeUsage: 1
725754
m_RayTracingMode: 2
755+
m_RayTraceProcedural: 0
726756
m_RenderingLayerMask: 1
727757
m_RendererPriority: 0
728758
m_Materials:
@@ -747,6 +777,7 @@ MeshRenderer:
747777
m_SortingLayerID: 0
748778
m_SortingLayer: 0
749779
m_SortingOrder: 0
780+
m_AdditionalVertexStreams: {fileID: 0}
750781
--- !u!33 &1737083698
751782
MeshFilter:
752783
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)