protected override Playable CreatePlayable(PlayableGraph graph, GameObject go, TimelineClip clip)
    {
        PlayableDirector director   = go.GetComponent <PlayableDirector>();
        RoleData         trackRole  = director.GetGenericBinding(this) as RoleData;
        CameraEffectClip cameraClip = clip.asset as CameraEffectClip;

        cameraClip.role = trackRole;
        Playable playable = base.CreatePlayable(graph, go, clip);

        return(playable);
    }
Esempio n. 2
0
    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
#if UNITY_EDITOR
        foreach (TimelineClip clip in m_Clips)
        {
            CameraEffectClip mouthClip = clip.asset as CameraEffectClip;
            // the template variable comes from classes made with the playable wizard
            CameraEffectBehaviour behaviour = mouthClip.template;
            mouthClip.camera = go.GetComponent <PlayableDirector>().GetGenericBinding(this) as Camera;
            // name the track with my variables value
            clip.displayName   = mouthClip.EffectName;
            mouthClip.director = go.GetComponent <PlayableDirector>();
        }
#endif
        ScriptPlayable <CameraEffectMixerBehaviour> playable = ScriptPlayable <CameraEffectMixerBehaviour> .Create(graph, inputCount);

        return(playable);
    }
Esempio n. 3
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        CameraEffectClip cameraeffect = (CameraEffectClip)property.serializedObject.targetObject;

        if (cameraeffect.camera == null)
        {
            EditorGUILayout.HelpBox("请先设置相机 ", MessageType.Error);
            return;
        }

        if (CameraEffectTypes.InitData == false)
        {
            LoadCameraEffects();
            CameraEffectTypes.InitData = true;
        }

        if (cameraeffect.EffectType != null)
        {
            cameraeffect.EffectObj = (MonoBehaviour)cameraeffect.camera.gameObject.GetComponent(cameraeffect.EffectType);
        }

        int newselect = EditorGUILayout.Popup("Select Effect:", cameraeffect.EffectIndex, CameraEffectTypes.getEnums());

        if (cameraeffect.EffectIndex != newselect)
        {
            cameraeffect.EffectIndex = newselect;
            cameraeffect.EffectName  = CameraEffectTypes.getName(cameraeffect.EffectIndex);
            if (cameraeffect.EffectObj != null)
            {
                GameObject.DestroyImmediate(cameraeffect.EffectObj);
            }
            cameraeffect.EffectType          = CameraEffectTypes.getType(cameraeffect.EffectIndex);
            cameraeffect.EffectObj           = (MonoBehaviour)cameraeffect.camera.gameObject.AddComponent(cameraeffect.EffectType);
            cameraeffect.Effect.exposedName  = cameraeffect.EffectType.ToString();
            cameraeffect.Effect.defaultValue = cameraeffect.EffectObj;
            cameraeffect.director.SetReferenceValue(cameraeffect.Effect.exposedName, cameraeffect.EffectObj);
            cameraeffect.EffectObj.enabled = false;
        }
        Type effectype = cameraeffect.EffectType;

        if (effectype != null)
        {
            FieldInfo[] fields = effectype.GetFields();
            foreach (FieldInfo f in fields)
            {
                if (f.IsPublic)
                {
                    if (f.FieldType == typeof(bool))
                    {
                        bool oldvalue = (bool)f.GetValue(cameraeffect.EffectObj);
                        bool newvalue = EditorGUILayout.Toggle(f.Name, oldvalue);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                }
                {
                    if (f.FieldType == typeof(string))
                    {
                        string oldvalue = (string)f.GetValue(cameraeffect.EffectObj);
                        string newvalue = EditorGUILayout.TextField(f.Name, oldvalue);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                    if (f.FieldType == typeof(float))
                    {
                        float oldvalue = (float)f.GetValue(cameraeffect.EffectObj);
                        float newvalue = EditorGUILayout.FloatField(f.Name, oldvalue);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                    if (f.FieldType == typeof(int))
                    {
                        int oldvalue = (int)f.GetValue(cameraeffect.EffectObj);
                        int newvalue = EditorGUILayout.IntField(f.Name, oldvalue);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                    if (f.FieldType == typeof(Vector2))
                    {
                        Vector2 oldvalue = (Vector2)f.GetValue(cameraeffect.EffectObj);
                        Vector2 newvalue = EditorGUILayout.Vector2Field(f.Name, oldvalue);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                    if (f.FieldType == typeof(Vector3))
                    {
                        Vector3 oldvalue = (Vector3)f.GetValue(cameraeffect.EffectObj);
                        Vector3 newvalue = EditorGUILayout.Vector3Field(f.Name, oldvalue);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                    if (f.FieldType == typeof(Vector4))
                    {
                        Vector4 oldvalue = (Vector4)f.GetValue(cameraeffect.EffectObj);
                        Vector4 newvalue = EditorGUILayout.Vector4Field(f.Name, oldvalue);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                    if (f.FieldType == typeof(Color))
                    {
                        Color oldvalue = (Color)f.GetValue(cameraeffect.EffectObj);
                        Color newvalue = EditorGUILayout.ColorField(f.Name, oldvalue);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                    if (f.FieldType == typeof(Texture))
                    {
                        Texture oldvalue = (Texture)f.GetValue(cameraeffect.EffectObj);
                        Texture newvalue = (Texture)EditorGUILayout.ObjectField(f.Name, oldvalue, typeof(Texture), false);
                        if (newvalue != oldvalue)
                        {
                            f.SetValue(cameraeffect.EffectObj, newvalue);
                        }
                    }
                }
            }
        }
    }