Example #1
0
        private static Object TransformObjectBeingDroppedAccordingToTrackRules(TrackAsset trackToReceiveClip, Object obj)
        {
            Object result;

            if (trackToReceiveClip is PlayableTrack && obj is MonoScript)
            {
                MonoScript monoScript = (MonoScript)obj;
                if (!typeof(IPlayableAsset).IsAssignableFrom(monoScript.GetClass()) || !typeof(Object).IsAssignableFrom(monoScript.GetClass()))
                {
                    Debug.LogError("The MonoScript " + monoScript.get_name() + " is not a valid PlayableAsset");
                    result = null;
                    return(result);
                }
                int num = InternalEditorUtility.CreateScriptableObjectUnchecked(monoScript);
                AssetDatabase.AddInstanceIDToAssetWithRandomFileId(num, trackToReceiveClip, true);
                obj = EditorUtility.InstanceIDToObject(num);
                if (obj == null)
                {
                    Debug.LogError("Unable to create PlayableAsset from MonoScript " + monoScript.get_name());
                }
            }
            result = obj;
            return(result);
        }