Ejemplo n.º 1
0
//----------------------------------------------------------------------------------------------------------------------    
    /// <inheritdoc/>
    public override ClipDrawOptions GetClipOptions(TimelineClip clip) {
        ClipDrawOptions         clipOptions = base.GetClipOptions(clip);
        SceneCachePlayableAsset asset       = clip.asset as SceneCachePlayableAsset;
        if (null == asset) {
            Debug.LogError("Asset is not a SceneCachePlayableAsset: " + clip.asset);
            return clipOptions;
        }
        
        SceneCacheClipData clipData = asset.GetBoundClipData();
        if (null == clipData) 
            return clipOptions;

        SceneCachePlayer scPlayer = asset.GetSceneCachePlayer();
        if (null == scPlayer) {
            clipOptions.errorText = NO_SCENE_CACHE_ASSIGNED_ERROR;
            return clipOptions;
        }

        LimitedAnimationController overrideLimitedAnimationController =asset.GetOverrideLimitedAnimationController();
        
        if (!scPlayer.IsLimitedAnimationOverrideable() && overrideLimitedAnimationController.IsEnabled()) {
            clipOptions.errorText = UNABLE_TO_OVERRIDE_LIMITED_ANIMATION_ERROR;
            return clipOptions;
        }

        clipOptions.tooltip = scPlayer.GetSceneCacheFilePath();

        return clipOptions;
    } 
//----------------------------------------------------------------------------------------------------------------------
    
    private void DrawLimitedAnimationGUI(SceneCachePlayableAsset scPlayableAsset) {
        SceneCachePlayer scPlayer = scPlayableAsset.GetSceneCachePlayer();
        
        bool disableScope = null == scPlayer;
        
        if (null != scPlayer) {
            disableScope |= (!scPlayer.IsLimitedAnimationOverrideable());
        }

        if (disableScope) {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.HelpBox(
                "Disabled because Limited Animation settings on the SceneCache GameObject is enabled, or the playback mode is set to interpolate", 
                MessageType.Warning
            );
            if (GUILayout.Button("Fix", GUILayout.Width(64), GUILayout.Height(36))) {
                scPlayer.AllowLimitedAnimationOverride();
                Repaint();
            }
            EditorGUILayout.EndHorizontal();
            
        }

        using (new EditorGUI.DisabledScope(disableScope)) {
            SceneCachePlayerEditorUtility.DrawLimitedAnimationGUI(scPlayableAsset.GetOverrideLimitedAnimationController(),
                m_scPlayableAsset, scPlayer);
        }
        
    }