Exemple #1
0
        void AddSerializedPlayableModifications(IPlayableAsset asset, AnimationClip clip)
        {
            var obj = asset as Object;

            if (obj == null)
            {
                return;
            }

            var driver = WindowState.previewDriver;

            if (driver == null || !AnimationMode.InAnimationMode(driver))
            {
                return;
            }

            var serializedObj = new SerializedObject(obj);
            var bindings      = AnimationClipCurveCache.Instance.GetCurveInfo(clip).bindings;
            var fields        = AnimatedParameterUtility.GetScriptPlayableFields(asset);

            // go through each binding and offset using the field name
            //  so the modification system can find the particle object using the asset as a root
            foreach (var b in bindings)
            {
                foreach (var f in fields)
                {
                    var propertyPath = f.Name + "." + b.propertyName;
                    if (serializedObj.FindProperty(propertyPath) != null)
                    {
                        DrivenPropertyManager.RegisterProperty(driver, obj, propertyPath);
                        break;
                    }
                }
            }
        }