From 9e79b8a8f2994b43d9271848e7fa0cb7fed5d3d8 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sat, 8 Oct 2016 02:19:06 +0700 Subject: [PATCH] SwfClip docs --- .../Postprocessors/SwfAssetPostprocessor.cs | 2 +- FTSources/FTRuntime/Sources/SwfClip.cs | 90 +++++++++++++++---- FTSources/FTRuntime/Sources/SwfManager.cs | 5 +- 3 files changed, 74 insertions(+), 23 deletions(-) diff --git a/FTSources/FTEditor/Sources/Postprocessors/SwfAssetPostprocessor.cs b/FTSources/FTEditor/Sources/Postprocessors/SwfAssetPostprocessor.cs index 85873fe..1a86985 100644 --- a/FTSources/FTEditor/Sources/Postprocessors/SwfAssetPostprocessor.cs +++ b/FTSources/FTEditor/Sources/Postprocessors/SwfAssetPostprocessor.cs @@ -464,7 +464,7 @@ namespace FTEditor.Postprocessors { var clips = GameObject.FindObjectsOfType(); foreach ( var clip in clips ) { if ( clip && clip.clip && asset.Clips.Contains(clip.clip) ) { - clip.UpdateAllProperties(); + clip.Internal_UpdateAllProperties(); } } } diff --git a/FTSources/FTRuntime/Sources/SwfClip.cs b/FTSources/FTRuntime/Sources/SwfClip.cs index 5b06420..52b7e23 100644 --- a/FTSources/FTRuntime/Sources/SwfClip.cs +++ b/FTSources/FTRuntime/Sources/SwfClip.cs @@ -15,13 +15,36 @@ namespace FTRuntime { // --------------------------------------------------------------------- // - // Properties + // Serialized fields // // --------------------------------------------------------------------- [Header("Sorting")] [SerializeField][SwfSortingLayer] - public string _sortingLayer = string.Empty; + string _sortingLayer = string.Empty; + [SerializeField] + int _sortingOrder = 0; + + [Header("Animation")] + [SerializeField] + Color _tint = Color.white; + [SerializeField] + SwfClipAsset _clip = null; + [SerializeField][HideInInspector] + string _sequence = string.Empty; + [SerializeField][HideInInspector] + int _currentFrame = 0; + + // --------------------------------------------------------------------- + // + // Properties + // + // --------------------------------------------------------------------- + + /// + /// Gets or sets the animation mesh renderer sorting layer + /// + /// The sorting layer public string sortingLayer { get { return _sortingLayer; } set { @@ -30,8 +53,10 @@ namespace FTRuntime { } } - [SerializeField] - public int _sortingOrder = 0; + /// + /// Gets or sets the animation mesh renderer sorting order + /// + /// The sorting order public int sortingOrder { get { return _sortingOrder; } set { @@ -40,9 +65,10 @@ namespace FTRuntime { } } - [Header("Animation")] - [SerializeField] - Color _tint = Color.white; + /// + /// Gets or sets the animation tint color + /// + /// The tint color public Color tint { get { return _tint; } set { @@ -51,8 +77,10 @@ namespace FTRuntime { } } - [SerializeField] - SwfClipAsset _clip = null; + /// + /// Gets or sets the animation asset (reset sequence and current frame) + /// + /// The animation asset public SwfClipAsset clip { get { return _clip; } set { @@ -63,8 +91,10 @@ namespace FTRuntime { } } - [SerializeField][HideInInspector] - string _sequence = string.Empty; + /// + /// Gets or sets the animation sequence (reset current frame) + /// + /// The animation sequence public string sequence { get { return _sequence; } set { @@ -74,8 +104,10 @@ namespace FTRuntime { } } - [SerializeField][HideInInspector] - int _currentFrame = 0; + /// + /// Gets or sets the animation current frame + /// + /// The animation current frame public int currentFrame { get { return _currentFrame; } set { @@ -84,6 +116,10 @@ namespace FTRuntime { } } + /// + /// Gets the current animation sequence frame count + /// + /// The frame count. public int frameCount { get { return _curSequence != null && _curSequence.Frames != null @@ -92,6 +128,10 @@ namespace FTRuntime { } } + /// + /// Gets the animation frame rate + /// + /// The frame rate. public float frameRate { get { return clip @@ -106,16 +146,26 @@ namespace FTRuntime { // // --------------------------------------------------------------------- + /// + /// Rewind current sequence to begin frame + /// public void ToBeginFrame() { currentFrame = 0; } + /// + /// Rewind current sequence to end frame + /// public void ToEndFrame() { currentFrame = frameCount > 0 ? frameCount - 1 : 0; } + /// + /// Rewind current sequence to previous frame + /// + /// true, if animation was rewound, false otherwise. public bool ToPrevFrame() { if ( currentFrame > 0 ) { --currentFrame; @@ -124,6 +174,10 @@ namespace FTRuntime { return false; } + /// + /// Rewind current sequence to next frame + /// + /// true, if animation was rewound, false otherwise. public bool ToNextFrame() { if ( currentFrame < frameCount - 1 ) { ++currentFrame; @@ -138,7 +192,7 @@ namespace FTRuntime { // // --------------------------------------------------------------------- - internal void InternalLateUpdate() { + public void Internal_LateUpdate() { if ( _meshFilter && _meshRenderer && _dirtyMesh ) { var baked_frame = GetCurrentBakedFrame(); if ( baked_frame != null ) { @@ -152,7 +206,7 @@ namespace FTRuntime { } } - public void UpdateAllProperties() { + public void Internal_UpdateAllProperties() { ClearCache(); ChangeTint(); ChangeClip(); @@ -256,7 +310,7 @@ namespace FTRuntime { // --------------------------------------------------------------------- void Awake() { - UpdateAllProperties(); + Internal_UpdateAllProperties(); } void OnEnable() { @@ -274,11 +328,11 @@ namespace FTRuntime { } void Reset() { - UpdateAllProperties(); + Internal_UpdateAllProperties(); } void OnValidate() { - UpdateAllProperties(); + Internal_UpdateAllProperties(); } } } \ No newline at end of file diff --git a/FTSources/FTRuntime/Sources/SwfManager.cs b/FTSources/FTRuntime/Sources/SwfManager.cs index 64cce97..6a21e05 100644 --- a/FTSources/FTRuntime/Sources/SwfManager.cs +++ b/FTSources/FTRuntime/Sources/SwfManager.cs @@ -3,9 +3,6 @@ using FTRuntime.Internal; using System.Collections.Generic; namespace FTRuntime { - /// - /// General manager for update and controlling animations and animation groups - /// [ExecuteInEditMode, DisallowMultipleComponent] public class SwfManager : MonoBehaviour { SwfAssocList _clips = new SwfAssocList(); @@ -247,7 +244,7 @@ namespace FTRuntime { for ( int i = 0, e = _clips.Count; i < e; ++i ) { var clip = _clips[i]; if ( clip ) { - clip.InternalLateUpdate(); + clip.Internal_LateUpdate(); } } }