Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeline Inspector Button #385

Open
fawad0dev opened this issue Apr 15, 2024 · 1 comment
Open

Timeline Inspector Button #385

fawad0dev opened this issue Apr 15, 2024 · 1 comment

Comments

@fawad0dev
Copy link

fawad0dev commented Apr 15, 2024

here is my Code for Time timeline Track

using NaughtyAttributes;
using UnityEngine;
using UnityEngine.Playables;

[System.Serializable]
public class CustomDialogBehaviour : PlayableBehaviour
{
    [ResizableTextArea] public string dialogText; // working fine
    [Button("ToUpper")] // not even displaying Btn
    public void ToUpper()
    {
        dialogText = dialogText.ToUpper();
    }
    public Color textColor;
    public Color cloudColor;
#if UNITY_EDITOR
    [UnityEditor.CustomEditor(typeof(CustomDialogBehaviour)), UnityEditor.CanEditMultipleObjects]
    public class CustomDialogBehaviourEditor : UnityEditor.Editor
    {
        public override void OnInspectorGUI()
        {
            if (GUILayout.Button("ToUpperCase")) //this also not displaying btn
            {
                var customDialogBehaviour = serializedObject.FindProperty("dialogText");
                customDialogBehaviour.stringValue = customDialogBehaviour.stringValue.ToUpper();
                serializedObject.ApplyModifiedProperties();
            }
            DrawDefaultInspector();
        }
    }
#endif
}
@fawad0dev
Copy link
Author

fawad0dev commented Apr 15, 2024

using NaughtyAttributes;
using Timeline.Samples;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
public class CustomDialogPlayableAsset : PlayableAsset, ITimelineClipAsset
{
    [NoFoldOut]
    [NotKeyable]
    public CustomDialogBehaviour template = new()
    {
        cloudColor = Color.white,
        textColor = Color.white,
        dialogText = ""
    };
    [Button("ToUpper")] // this also not displaying any btn
    void ToUpper()
    {
        UnityEditor.Undo.RecordObject(this, "ToUpperCase");
        template.dialogText = template.dialogText.ToUpper();
        UnityEditor.EditorUtility.SetDirty(this);
    }
    public ClipCaps clipCaps
    {
        get { return ClipCaps.Blending; }
    }
    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        return ScriptPlayable<CustomDialogBehaviour>.Create(graph, template);
    }
}
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(CustomDialogPlayableAsset)), UnityEditor.CanEditMultipleObjects]
public class CustomDialogPlayableAssetEditor : UnityEditor.Editor
{
    public override void OnInspectorGUI()
    {
        if (GUILayout.Button("ToUpperCase")) // this is displaying Btn
        {
            var customDialogBehaviour = target as CustomDialogPlayableAsset;
            customDialogBehaviour.template.dialogText = customDialogBehaviour.template.dialogText.ToUpper();
            serializedObject.ApplyModifiedProperties();
        }
        DrawDefaultInspector();
    }
}
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant