├── .gitattributes ├── .gitignore ├── DefaultPlayablesDocumentation.pdf ├── DefaultPlayablesDocumentation.pdf.meta ├── Editor.meta ├── Editor ├── LightControl.meta ├── LightControl │ ├── LightControlDrawer.cs │ └── LightControlDrawer.cs.meta ├── ScreenFader.meta ├── ScreenFader │ ├── ScreenFaderDrawer.cs │ └── ScreenFaderDrawer.cs.meta ├── TextSwitcher.meta ├── TextSwitcher │ ├── TextSwitcherDrawer.cs │ └── TextSwitcherDrawer.cs.meta ├── TimeDilation.meta ├── TimeDilation │ ├── TimeDilationDrawer.cs │ └── TimeDilationDrawer.cs.meta ├── TimelinePlayableWizard.cs ├── TimelinePlayableWizard.cs.meta ├── TransformTween.meta ├── TransformTween │ ├── TransformTweenDrawer.cs │ └── TransformTweenDrawer.cs.meta ├── com.uap.defaultplayables.editor.asmdef └── com.uap.defaultplayables.editor.asmdef.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime ├── LightControl.meta ├── LightControl │ ├── LightControlBehaviour.cs │ ├── LightControlBehaviour.cs.meta │ ├── LightControlClip.cs │ ├── LightControlClip.cs.meta │ ├── LightControlMixerBehaviour.cs │ ├── LightControlMixerBehaviour.cs.meta │ ├── LightControlTrack.cs │ └── LightControlTrack.cs.meta ├── NavMeshAgentControl.meta ├── NavMeshAgentControl │ ├── NavMeshAgentControlBehaviour.cs │ ├── NavMeshAgentControlBehaviour.cs.meta │ ├── NavMeshAgentControlClip.cs │ ├── NavMeshAgentControlClip.cs.meta │ ├── NavMeshAgentControlMixerBehaviour.cs │ ├── NavMeshAgentControlMixerBehaviour.cs.meta │ ├── NavMeshAgentControlTrack.cs │ └── NavMeshAgentControlTrack.cs.meta ├── ScreenFader.meta ├── ScreenFader │ ├── ScreenFaderBehaviour.cs │ ├── ScreenFaderBehaviour.cs.meta │ ├── ScreenFaderClip.cs │ ├── ScreenFaderClip.cs.meta │ ├── ScreenFaderMixerBehaviour.cs │ ├── ScreenFaderMixerBehaviour.cs.meta │ ├── ScreenFaderTrack.cs │ └── ScreenFaderTrack.cs.meta ├── TextSwitcher.meta ├── TextSwitcher │ ├── TextSwitcherBehaviour.cs │ ├── TextSwitcherBehaviour.cs.meta │ ├── TextSwitcherClip.cs │ ├── TextSwitcherClip.cs.meta │ ├── TextSwitcherMixerBehaviour.cs │ ├── TextSwitcherMixerBehaviour.cs.meta │ ├── TextSwitcherTrack.cs │ └── TextSwitcherTrack.cs.meta ├── TimeDilation.meta ├── TimeDilation │ ├── TimeDilationBehaviour.cs │ ├── TimeDilationBehaviour.cs.meta │ ├── TimeDilationClip.cs │ ├── TimeDilationClip.cs.meta │ ├── TimeDilationMixerBehaviour.cs │ ├── TimeDilationMixerBehaviour.cs.meta │ ├── TimeDilationTrack.cs │ └── TimeDilationTrack.cs.meta ├── TransformTween.meta ├── TransformTween │ ├── TransformTweenBehaviour.cs │ ├── TransformTweenBehaviour.cs.meta │ ├── TransformTweenClip.cs │ ├── TransformTweenClip.cs.meta │ ├── TransformTweenMixerBehaviour.cs │ ├── TransformTweenMixerBehaviour.cs.meta │ ├── TransformTweenTrack.cs │ └── TransformTweenTrack.cs.meta ├── Video.meta ├── Video │ ├── VideoPlayableBehaviour.cs │ ├── VideoPlayableBehaviour.cs.meta │ ├── VideoSchedulerPlayableBehaviour.cs │ ├── VideoSchedulerPlayableBehaviour.cs.meta │ ├── VideoScriptPlayableAsset.cs │ ├── VideoScriptPlayableAsset.cs.meta │ ├── VideoScriptPlayableTrack.cs │ └── VideoScriptPlayableTrack.cs.meta ├── com.uap.defaultplayables.runtime.asmdef └── com.uap.defaultplayables.runtime.asmdef.meta ├── VideoScriptPlayable.pdf ├── VideoScriptPlayable.pdf.meta ├── package.json └── package.json.meta /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | 38 | .idea/ 39 | Assets/Plugins/Editor/JetBrains* 40 | -------------------------------------------------------------------------------- /DefaultPlayablesDocumentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UnityAssetPackages/DefaultPlayables/e1a677e83b2797d0d64aa57d7b6d55c485ce8cd2/DefaultPlayablesDocumentation.pdf -------------------------------------------------------------------------------- /DefaultPlayablesDocumentation.pdf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e951343000f41f4994e0e36b383bd08 3 | timeCreated: 1499765480 4 | licenseType: Store 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89ec3eb5642c0f84d9f5090b2ca93a14 3 | folderAsset: yes 4 | timeCreated: 1490191884 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Editor/LightControl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01cfda49307e46248bd868ab09d47ace 3 | folderAsset: yes 4 | timeCreated: 1496915000 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Editor/LightControl/LightControlDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | 5 | [CustomPropertyDrawer(typeof(LightControlBehaviour))] 6 | public class LightControlDrawer : PropertyDrawer 7 | { 8 | public override float GetPropertyHeight (SerializedProperty property, GUIContent label) 9 | { 10 | int fieldCount = 4; 11 | return fieldCount * EditorGUIUtility.singleLineHeight; 12 | } 13 | 14 | public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 15 | { 16 | SerializedProperty colorProp = property.FindPropertyRelative("color"); 17 | SerializedProperty intensityProp = property.FindPropertyRelative("intensity"); 18 | SerializedProperty bounceIntensityProp = property.FindPropertyRelative("bounceIntensity"); 19 | SerializedProperty rangeProp = property.FindPropertyRelative("range"); 20 | 21 | Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); 22 | EditorGUI.PropertyField(singleFieldRect, colorProp); 23 | 24 | singleFieldRect.y += EditorGUIUtility.singleLineHeight; 25 | EditorGUI.PropertyField(singleFieldRect, intensityProp); 26 | 27 | singleFieldRect.y += EditorGUIUtility.singleLineHeight; 28 | EditorGUI.PropertyField(singleFieldRect, bounceIntensityProp); 29 | 30 | singleFieldRect.y += EditorGUIUtility.singleLineHeight; 31 | EditorGUI.PropertyField(singleFieldRect, rangeProp); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Editor/LightControl/LightControlDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a217f65052ddf094ba45e737b2428b1c 3 | timeCreated: 1496915002 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Editor/ScreenFader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b53f46f9af38aef4c8014c759eae0bd9 3 | folderAsset: yes 4 | timeCreated: 1496916561 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Editor/ScreenFader/ScreenFaderDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.UI; 5 | 6 | [CustomPropertyDrawer(typeof(ScreenFaderBehaviour))] 7 | public class ScreenFaderDrawer : PropertyDrawer 8 | { 9 | public override float GetPropertyHeight (SerializedProperty property, GUIContent label) 10 | { 11 | int fieldCount = 1; 12 | return fieldCount * EditorGUIUtility.singleLineHeight; 13 | } 14 | 15 | public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 16 | { 17 | SerializedProperty colorProp = property.FindPropertyRelative("color"); 18 | 19 | Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); 20 | EditorGUI.PropertyField(singleFieldRect, colorProp); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Editor/ScreenFader/ScreenFaderDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7075b31fb4bae504f8480419ce90246f 3 | timeCreated: 1496916563 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Editor/TextSwitcher.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b912234a0cf57714d8cec5d0a338786d 3 | folderAsset: yes 4 | timeCreated: 1496915577 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Editor/TextSwitcher/TextSwitcherDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.UI; 5 | 6 | [CustomPropertyDrawer(typeof(TextSwitcherBehaviour))] 7 | public class TextSwitcherDrawer : PropertyDrawer 8 | { 9 | public override float GetPropertyHeight (SerializedProperty property, GUIContent label) 10 | { 11 | int fieldCount = 3; 12 | return fieldCount * EditorGUIUtility.singleLineHeight; 13 | } 14 | 15 | public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 16 | { 17 | SerializedProperty colorProp = property.FindPropertyRelative("color"); 18 | SerializedProperty fontSizeProp = property.FindPropertyRelative("fontSize"); 19 | SerializedProperty textProp = property.FindPropertyRelative("text"); 20 | 21 | Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); 22 | EditorGUI.PropertyField(singleFieldRect, colorProp); 23 | 24 | singleFieldRect.y += EditorGUIUtility.singleLineHeight; 25 | EditorGUI.PropertyField(singleFieldRect, fontSizeProp); 26 | 27 | singleFieldRect.y += EditorGUIUtility.singleLineHeight; 28 | EditorGUI.PropertyField(singleFieldRect, textProp); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Editor/TextSwitcher/TextSwitcherDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d10fec9d6fdea024293153308aa74ef7 3 | timeCreated: 1496915579 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Editor/TimeDilation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5d00dcf58e5bec4888a9be9ecf3d1b4 3 | folderAsset: yes 4 | timeCreated: 1491318587 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Editor/TimeDilation/TimeDilationDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | [CustomPropertyDrawer(typeof(TimeDilationBehaviour))] 5 | public class TimeDilationDrawer : PropertyDrawer 6 | { 7 | public override float GetPropertyHeight (SerializedProperty property, GUIContent label) 8 | { 9 | int fieldCount = 1; 10 | return fieldCount * EditorGUIUtility.singleLineHeight; 11 | } 12 | 13 | public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 14 | { 15 | SerializedProperty timeScaleProp = property.FindPropertyRelative("timeScale"); 16 | 17 | Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); 18 | EditorGUI.PropertyField(singleFieldRect, timeScaleProp); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Editor/TimeDilation/TimeDilationDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96853521ef6ea974d96cf7ef72f7c6a7 3 | timeCreated: 1491318587 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Editor/TimelinePlayableWizard.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.CodeDom.Compiler; 6 | using System.Reflection; 7 | using UnityEditor; 8 | using UnityEngine; 9 | using UnityEngine.Timeline; 10 | 11 | public class TimelinePlayableWizard : EditorWindow 12 | { 13 | public class Variable : IComparable 14 | { 15 | public string name; 16 | public UsableType usableType; 17 | 18 | int m_TypeIndex; 19 | 20 | public Variable (string name, UsableType usableType) 21 | { 22 | this.name = name; 23 | this.usableType = usableType; 24 | } 25 | 26 | public bool GUI (UsableType[] usableTypes) 27 | { 28 | bool removeThis = false; 29 | EditorGUILayout.BeginHorizontal(); 30 | name = EditorGUILayout.TextField(name); 31 | m_TypeIndex = EditorGUILayout.Popup(m_TypeIndex, UsableType.GetNamewithSortingArray (usableTypes)); 32 | usableType = usableTypes[m_TypeIndex]; 33 | if (GUILayout.Button("Remove", GUILayout.Width(60f))) 34 | { 35 | removeThis = true; 36 | } 37 | EditorGUILayout.EndHorizontal(); 38 | 39 | return removeThis; 40 | } 41 | 42 | public int CompareTo (object obj) 43 | { 44 | if (obj == null) 45 | return 1; 46 | 47 | UsableType other = (UsableType)obj; 48 | 49 | if (other == null) 50 | throw new ArgumentException("This object is not a Variable."); 51 | 52 | return name.ToLower().CompareTo(other.name.ToLower()); 53 | } 54 | 55 | public static UsableType[] GetUsableTypesFromVariableArray (Variable[] variables) 56 | { 57 | UsableType[] usableTypes = new UsableType[variables.Length]; 58 | for (int i = 0; i < usableTypes.Length; i++) 59 | { 60 | usableTypes[i] = variables[i].usableType; 61 | } 62 | return usableTypes; 63 | } 64 | } 65 | 66 | 67 | public class UsableType : IComparable 68 | { 69 | public readonly string name; 70 | public readonly string nameWithSorting; 71 | public readonly string additionalNamespace; 72 | public readonly GUIContent guiContentWithSorting; 73 | public readonly Type type; 74 | 75 | public readonly string[] unrequiredNamespaces = 76 | { 77 | "UnityEngine", 78 | "UnityEngine.Timeline", 79 | "UnityEngine.Playables" 80 | }; 81 | public const string blankAdditionalNamespace = ""; 82 | 83 | const string k_NameForNullType = "None"; 84 | 85 | public UsableType (Type usableType) 86 | { 87 | type = usableType; 88 | 89 | if (type != null) 90 | { 91 | name = usableType.Name; 92 | nameWithSorting = name.ToUpper ()[0] + "/" + name; 93 | additionalNamespace = unrequiredNamespaces.All (t => usableType.Namespace != t) ? usableType.Namespace : blankAdditionalNamespace; 94 | } 95 | else 96 | { 97 | name = k_NameForNullType; 98 | nameWithSorting = k_NameForNullType; 99 | additionalNamespace = blankAdditionalNamespace; 100 | } 101 | 102 | guiContentWithSorting = new GUIContent(nameWithSorting); 103 | } 104 | 105 | public UsableType (string name) 106 | { 107 | this.name = name; 108 | nameWithSorting = name.ToUpper()[0] + "/" + name; 109 | additionalNamespace = blankAdditionalNamespace; 110 | guiContentWithSorting = new GUIContent(nameWithSorting); 111 | } 112 | 113 | public int CompareTo (object obj) 114 | { 115 | if (obj == null) 116 | return 1; 117 | 118 | UsableType other = (UsableType)obj; 119 | 120 | if(other == null) 121 | throw new ArgumentException("This object is not a UsableType."); 122 | 123 | return name.ToLower().CompareTo (other.name.ToLower()); 124 | } 125 | 126 | public static UsableType[] GetUsableTypeArray (Type[] types, params UsableType[] additionalUsableTypes) 127 | { 128 | List usableTypeList = new List (); 129 | for (int i = 0; i < types.Length; i++) 130 | { 131 | usableTypeList.Add (new UsableType (types[i])); 132 | } 133 | usableTypeList.AddRange (additionalUsableTypes); 134 | return usableTypeList.ToArray (); 135 | } 136 | 137 | public static UsableType[] AmalgamateUsableTypes (UsableType[] usableTypeArray, params UsableType[] usableTypes) 138 | { 139 | List usableTypeList = new List (); 140 | for (int i = 0; i < usableTypes.Length; i++) 141 | { 142 | usableTypeList.Add (usableTypes[i]); 143 | } 144 | usableTypeList.AddRange(usableTypeArray); 145 | return usableTypeList.ToArray(); 146 | } 147 | 148 | public static string[] GetNamewithSortingArray(UsableType[] usableTypes) 149 | { 150 | if (usableTypes == null || usableTypes.Length == 0) 151 | return new string[0]; 152 | 153 | string[] displayNames = new string[usableTypes.Length]; 154 | for (int i = 0; i < displayNames.Length; i++) 155 | { 156 | displayNames[i] = usableTypes[i].nameWithSorting; 157 | } 158 | return displayNames; 159 | } 160 | 161 | public static GUIContent[] GetGUIContentWithSortingArray (UsableType[] usableTypes) 162 | { 163 | if(usableTypes == null || usableTypes.Length == 0) 164 | return new GUIContent[0]; 165 | 166 | GUIContent[] guiContents = new GUIContent[usableTypes.Length]; 167 | for (int i = 0; i < guiContents.Length; i++) 168 | { 169 | guiContents[i] = usableTypes[i].guiContentWithSorting; 170 | } 171 | return guiContents; 172 | } 173 | 174 | public static string[] GetDistinctAdditionalNamespaces (UsableType[] usableTypes) 175 | { 176 | if (usableTypes == null || usableTypes.Length == 0) 177 | return new string[0]; 178 | 179 | string[] namespaceArray = new string[usableTypes.Length]; 180 | for (int i = 0; i < namespaceArray.Length; i++) 181 | { 182 | namespaceArray[i] = usableTypes[i].additionalNamespace; 183 | } 184 | return namespaceArray.Distinct().ToArray(); 185 | } 186 | } 187 | 188 | 189 | public class UsableProperty : IComparable 190 | { 191 | public enum Usability 192 | { 193 | Blendable, Assignable, Not 194 | } 195 | 196 | public enum UsablePropertyType 197 | { 198 | Property, Field 199 | } 200 | 201 | public string type; 202 | public string name; 203 | public string defaultValue; 204 | public Usability usability; 205 | public UsablePropertyType usablePropertyType; 206 | public PropertyInfo propertyInfo; 207 | public FieldInfo fieldInfo; 208 | 209 | int m_TypeIndex; 210 | 211 | public string NameWithCaptial 212 | { 213 | get { return name.First().ToString().ToUpper() + name.Substring(1); } 214 | } 215 | 216 | public string NameAsPrivate 217 | { 218 | get { return "m_" + NameWithCaptial; } 219 | } 220 | 221 | public string NameAsPrivateDefault 222 | { 223 | get { return "m_Default" + NameWithCaptial; } 224 | } 225 | 226 | public string NameAsPrivateAssigned 227 | { 228 | get { return "m_Assigned" + NameWithCaptial; } 229 | } 230 | 231 | public string NameAsLocalBlended 232 | { 233 | get { return "blended" + NameWithCaptial; } 234 | } 235 | 236 | public string NameAsLocalSerializedProperty 237 | { 238 | get { return name + "Prop"; } 239 | } 240 | 241 | public UsableProperty (PropertyInfo propertyInfo) 242 | { 243 | usablePropertyType = UsablePropertyType.Property; 244 | this.propertyInfo = propertyInfo; 245 | 246 | if (propertyInfo.PropertyType.Name == "Single") 247 | type = "float"; 248 | else if (propertyInfo.PropertyType.Name == "Int32") 249 | type = "int"; 250 | else if (propertyInfo.PropertyType.Name == "Double") 251 | type = "double"; 252 | else if (propertyInfo.PropertyType.Name == "Boolean") 253 | type = "bool"; 254 | else if (propertyInfo.PropertyType.Name == "String") 255 | type = "string"; 256 | else 257 | type = propertyInfo.PropertyType.Name; 258 | 259 | name = propertyInfo.Name; 260 | 261 | if (IsTypeBlendable(propertyInfo.PropertyType)) 262 | usability = Usability.Blendable; 263 | else if (IsTypeAssignable(propertyInfo.PropertyType)) 264 | usability = Usability.Assignable; 265 | else 266 | usability = Usability.Not; 267 | } 268 | 269 | public UsableProperty (FieldInfo fieldInfo) 270 | { 271 | usablePropertyType = UsablePropertyType.Field; 272 | this.fieldInfo = fieldInfo; 273 | 274 | if (fieldInfo.FieldType.Name == "Single") 275 | type = "float"; 276 | else if (fieldInfo.FieldType.Name == "Int32") 277 | type = "int"; 278 | else if (fieldInfo.FieldType.Name == "Double") 279 | type = "double"; 280 | else if (fieldInfo.FieldType.Name == "Boolean") 281 | type = "bool"; 282 | else if (fieldInfo.FieldType.Name == "String") 283 | type = "string"; 284 | else 285 | type = fieldInfo.FieldType.Name; 286 | 287 | name = fieldInfo.Name; 288 | 289 | if (IsTypeBlendable(fieldInfo.FieldType)) 290 | usability = Usability.Blendable; 291 | else if (IsTypeAssignable(fieldInfo.FieldType)) 292 | usability = Usability.Assignable; 293 | else 294 | usability = Usability.Not; 295 | } 296 | 297 | public string ZeroValueAsString () 298 | { 299 | if(usability != Usability.Blendable) 300 | throw new UnityException("UsableType is not blendable, shouldn't be looking for zero value as string."); 301 | 302 | switch (type) 303 | { 304 | case "float": 305 | return "0f"; 306 | case "int": 307 | return "0"; 308 | case "double": 309 | return "0.0"; 310 | case "Vector2": 311 | return "Vector2.zero"; 312 | case "Vector3": 313 | return "Vector3.zero"; 314 | case "Color": 315 | return "Color.clear"; 316 | } 317 | return ""; 318 | } 319 | 320 | public void CreateSettingDefaultValueString (Component defaultValuesComponent) 321 | { 322 | if (defaultValuesComponent == null) 323 | { 324 | defaultValue = ""; 325 | return; 326 | } 327 | 328 | object defaultValueObj = usablePropertyType == UsablePropertyType.Property ? propertyInfo.GetValue (defaultValuesComponent, null) : fieldInfo.GetValue (defaultValuesComponent); 329 | 330 | switch (type) 331 | { 332 | case "float": 333 | float defaultFloatValue = (float)defaultValueObj; 334 | defaultValue = defaultFloatValue + "f"; 335 | break; 336 | case "int": 337 | int defaultIntValue = (int)defaultValueObj; 338 | defaultValue = defaultIntValue.ToString(); 339 | break; 340 | case "double": 341 | double defaultDoubleValue = (double)defaultValueObj; 342 | defaultValue = defaultDoubleValue.ToString(); 343 | break; 344 | case "Vector2": 345 | Vector2 defaultVector2Value = (Vector2)defaultValueObj; 346 | defaultValue = "new Vector2(" + defaultVector2Value.x + "f, " + defaultVector2Value.y + "f)"; 347 | break; 348 | case "Vector3": 349 | Vector3 defaultVector3Value = (Vector3)defaultValueObj; 350 | defaultValue = "new Vector3(" + defaultVector3Value.x + "f, " + defaultVector3Value.y + "f, " + defaultVector3Value.z + "f)"; 351 | break; 352 | case "Color": 353 | Color defaultColorValue = (Color)defaultValueObj; 354 | defaultValue = "new Color(" + defaultColorValue.r + "f, " + defaultColorValue.g + "f, " + defaultColorValue.b + "f, " + defaultColorValue.a + "f)"; 355 | break; 356 | case "string": 357 | defaultValue = "\"" + defaultValueObj + "\""; 358 | break; 359 | case "bool": 360 | bool defaultBoolValue = (bool)defaultValueObj; 361 | defaultValue = defaultBoolValue.ToString ().ToLower(); 362 | break; 363 | default: 364 | Enum defaultEnumValue = (Enum)defaultValueObj; 365 | Type enumSystemType = defaultEnumValue.GetType (); 366 | string[] splits = enumSystemType.ToString().Split('+'); 367 | string enumType = splits[splits.Length - 1]; 368 | string enumConstantName = Enum.GetName (enumSystemType, defaultEnumValue); 369 | defaultValue = enumType + "." + enumConstantName; 370 | break; 371 | } 372 | } 373 | 374 | public bool GUI (List allUsableProperties) 375 | { 376 | bool removeThis = false; 377 | EditorGUILayout.BeginHorizontal(); 378 | m_TypeIndex = EditorGUILayout.Popup(m_TypeIndex, GetNameWithSortingArray (allUsableProperties)); 379 | type = allUsableProperties[m_TypeIndex].type; 380 | name = allUsableProperties[m_TypeIndex].name; 381 | usablePropertyType = allUsableProperties[m_TypeIndex].usablePropertyType; 382 | propertyInfo = allUsableProperties[m_TypeIndex].propertyInfo; 383 | fieldInfo = allUsableProperties[m_TypeIndex].fieldInfo; 384 | usability = allUsableProperties[m_TypeIndex].usability; 385 | if (GUILayout.Button("Remove", GUILayout.Width(60f))) 386 | { 387 | removeThis = true; 388 | } 389 | EditorGUILayout.EndHorizontal(); 390 | return removeThis; 391 | } 392 | 393 | public int CompareTo(object obj) 394 | { 395 | if (obj == null) 396 | return 1; 397 | 398 | UsableType other = (UsableType)obj; 399 | 400 | if (other == null) 401 | throw new ArgumentException("This object is not a UsableProperty."); 402 | 403 | return name.ToLower().CompareTo(other.name.ToLower()); 404 | } 405 | 406 | public static string[] GetNameWithSortingArray (List usableProperties) 407 | { 408 | string[] returnVal = new string[usableProperties.Count]; 409 | for (int i = 0; i < returnVal.Length; i++) 410 | { 411 | returnVal[i] = usableProperties[i].name; 412 | } 413 | return returnVal; 414 | } 415 | 416 | public UsableProperty GetDuplicate () 417 | { 418 | UsableProperty duplicate = usablePropertyType == UsablePropertyType.Property ? new UsableProperty (propertyInfo) : new UsableProperty (fieldInfo); 419 | duplicate.defaultValue = defaultValue; 420 | return duplicate; 421 | } 422 | } 423 | 424 | public enum CreationError 425 | { 426 | NoError, 427 | PlayableAssetAlreadyExists, 428 | PlayableBehaviourAlreadyExists, 429 | PlayableBehaviourMixerAlreadyExists, 430 | TrackAssetAlreadyExists, 431 | PlayableDrawerAlreadyExists, 432 | } 433 | 434 | 435 | public bool showHelpBoxes = true; 436 | public string playableName = ""; 437 | public bool isStandardBlendPlayable; 438 | public UsableType trackBinding; 439 | public Component defaultValuesComponent; 440 | public List exposedReferences = new List (); 441 | public List playableBehaviourVariables = new List (); 442 | public List standardBlendPlayableProperties = new List (); 443 | public ClipCaps clipCaps; 444 | /*public bool setClipDefaults; 445 | public float clipDefaultDurationSeconds = 5f; 446 | public float clipDefaultEaseInSeconds; 447 | public float clipDefaultEaseOutSeconds; 448 | public float clipDefaultClipInSeconds; 449 | public float clipDefaultSpeedMultiplier = 1f;*/ 450 | public Color trackColor = new Color(0.855f, 0.8623f, 0.870f); 451 | 452 | int m_TrackBindingTypeIndex; 453 | int m_ComponentBindingTypeIndex; 454 | PropertyInfo[] m_TrackBindingProperties; 455 | FieldInfo[] m_TrackBindingFields; 456 | List m_TrackBindingUsableProperties = new List (); 457 | bool m_CreateDrawer; 458 | bool m_CreateButtonPressed; 459 | Vector2 m_ScrollViewPos; 460 | CreationError m_CreationError; 461 | 462 | readonly GUIContent m_ShowHelpBoxesContent = new GUIContent("Show Help", "Do you want to see the help boxes as part of this wizard?"); 463 | readonly GUIContent m_PlayableNameContent = new GUIContent("Playable Name", "This is the name that will represent the playable. E.G. TransformTween. It will be the basis for the class names so it is best not to use the postfixes: 'Clip', 'Behaviour', 'MixerBehaviour' or 'Drawer'."); 464 | readonly GUIContent m_StandardBlendPlayableContent = new GUIContent("Standard Blend Playable", "Often when creating a playable it's intended purpose is just to briefly override the properties of a component for the playable's duration and then blend back to the defaults. For example a playable that changes the color of a Light but changes it back. To make a playable with this functionality, check this box."); 465 | readonly GUIContent m_TrackBindingTypeContent = new GUIContent("Track Binding Type", "This is the type of object the Playable will affect. E.G. To affect the position choose Transform."); 466 | readonly GUIContent m_DefaultValuesComponentContent = new GUIContent("Default Values", "When the scripts are created, each of the selected properties are assigned a default from the selected Component. If this is left blank no defaults will be used."); 467 | readonly GUIContent m_ExposedReferencesContent = new GUIContent("Exposed References", "Exposed References are references to objects in a scene that your Playable needs. For example, if you want to tween between two Transforms, they will need to be Exposed References."); 468 | readonly GUIContent m_BehaviourVariablesContent = new GUIContent("Behaviour Variables", "Behaviour Variables are all the variables you wish to use in your playable that do NOT need a reference to something in a scene. For example a float for speed."); 469 | readonly GUIContent m_TrackColorContent = new GUIContent("Track Color", "Timeline tracks have a colored outline, use this to select that color for your track."); 470 | readonly GUIContent m_CreateDrawerContent = new GUIContent("Create Drawer?", "Checking this box will enable the creation of a PropertyDrawer for your playable. Having this script will make it easier to customise how your playable appears in the inspector."); 471 | readonly GUIContent m_StandardBlendPlayablePropertiesContent = new GUIContent("Standard Blend Playable Properties", "Having already selected a Track Binding type, you can select the properties of the bound component you want the playable to affect. For example, if your playable is bound to a Transform, you can affect the position property. Note that changing the component binding will clear the list of properties."); 472 | readonly GUIContent m_ClipCapsContent = new GUIContent("Clip Caps", "Clip Caps are used to change the way Timelines work with your playables. For example, enabling Blending will mean that your playables can blend when they overlap and have ease in and out durations. To find out a little about each hover the cursor over the options. For details, please see the documentation."); 473 | readonly GUIContent m_CCNoneContent = new GUIContent("None", "Your playable supports none of the features below."); 474 | readonly GUIContent m_CCLoopingContent = new GUIContent("Looping", "Your playable has a specified time that it takes and will start again after it finishes until the clip's duration has played."); 475 | readonly GUIContent m_CCExtrapolationContent = new GUIContent("Extrapolation", "Your playable will persist beyond its end time and its results will continue until the next clip is encountered."); 476 | readonly GUIContent m_CCClipInContent = new GUIContent("Clip In", "Your playable need not be at the start of the Timeline."); 477 | readonly GUIContent m_CCSpeedMultiplierContent = new GUIContent("Speed Multiplier", "Your playable supports changes to the time scale."); 478 | readonly GUIContent m_CCBlendingContent = new GUIContent("Blending", "Your playable supports overlapping of clips to blend between them."); 479 | readonly GUIContent m_CCAllContent = new GUIContent("All", "Your playable supports all of the above features."); 480 | /*readonly GUIContent m_SetClipDefaultsContent = new GUIContent("Set Clip Defaults", "Do you want to set the default timings and other settings for clips when they are first created?"); 481 | readonly GUIContent m_ClipDefaultsContent = new GUIContent("Clip Defaults"); 482 | readonly GUIContent m_CDClipTimingContent = new GUIContent("Clip Timing", "Various settings that affect the durations over which the playable will be active."); 483 | readonly GUIContent m_CDDurationContent = new GUIContent("Duration", "The default length of the clip in seconds."); 484 | readonly GUIContent m_CDEaseInContent = new GUIContent("Ease In Duration", "The default duration over which the clip's weight increases to one. When clips are overlapped, this is controlled by their overlap. A clip requires the Blending ClipCap to support this."); 485 | readonly GUIContent m_CDEaseOutContent = new GUIContent("Ease Out Duration", "The default duration over which the clip's weight decreases to zero. When clips are overlapped, this is controlled by their overlap. A clip requires the Blending ClipCap to support this."); 486 | readonly GUIContent m_CDClipInContent = new GUIContent("Clip In", "The length of time after the start that the clip should start. A clip requires the ClipIn ClipCap to support this."); 487 | readonly GUIContent m_CDSpeedMultiplierContent = new GUIContent("Speed Multiplier", "The amount a clip's time dependent aspects will speed up or slow down by. A clip requires the SpeedMultiplier ClipCap to support this."); 488 | */ 489 | const string k_Tab = " "; 490 | const string k_ShowHelpBoxesKey = "TimelinePlayableWizard_ShowHelpBoxes"; 491 | const string k_TimelineClipAssetSuffix = "Clip"; 492 | const string k_TimelineClipBehaviourSuffix = "Behaviour"; 493 | const string k_PlayableBehaviourMixerSuffix = "MixerBehaviour"; 494 | const string k_TrackAssetSuffix = "Track"; 495 | const string k_PropertyDrawerSuffix = "Drawer"; 496 | const int k_PlayableNameCharLimit = 64; 497 | const float k_WindowWidth = 500f; 498 | const float k_MaxWindowHeight = 800f; 499 | const float k_ScreenSizeWindowBuffer = 50f; 500 | 501 | static UsableType[] s_ComponentTypes; 502 | static UsableType[] s_TrackBindingTypes; 503 | static UsableType[] s_ExposedReferenceTypes; 504 | static UsableType[] s_BehaviourVariableTypes; 505 | static Type[] s_BlendableTypes = 506 | { 507 | typeof(float), typeof(int), typeof(double), typeof(Vector2), typeof(Vector3), typeof(Color), 508 | }; 509 | static Type[] s_AssignableTypes = 510 | { 511 | typeof(string), typeof(bool) 512 | }; 513 | static string[] s_DisallowedPropertyNames = 514 | { 515 | "name", 516 | }; 517 | 518 | [MenuItem("Window/Timeline Playable Wizard...")] 519 | static void CreateWindow () 520 | { 521 | TimelinePlayableWizard wizard = GetWindow(true, "Timeline Playable Wizard", true); 522 | 523 | Vector2 position = Vector2.zero; 524 | SceneView sceneView = SceneView.lastActiveSceneView; 525 | if (sceneView != null) 526 | position = new Vector2(sceneView.position.x, sceneView.position.y); 527 | wizard.position = new Rect(position.x + k_ScreenSizeWindowBuffer, position.y + k_ScreenSizeWindowBuffer, k_WindowWidth, Mathf.Min(Screen.currentResolution.height - k_ScreenSizeWindowBuffer, k_MaxWindowHeight)); 528 | 529 | wizard.showHelpBoxes = EditorPrefs.GetBool (k_ShowHelpBoxesKey); 530 | wizard.Show(); 531 | 532 | Init (); 533 | } 534 | 535 | static void Init () 536 | { 537 | Type[] componentTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).Where(t => typeof(Component).IsAssignableFrom(t)).Where (t => t.IsPublic).ToArray(); 538 | 539 | List componentUsableTypesList = UsableType.GetUsableTypeArray(componentTypes).ToList(); 540 | componentUsableTypesList.Sort(); 541 | s_ComponentTypes = componentUsableTypesList.ToArray (); 542 | 543 | UsableType gameObjectUsableType = new UsableType(typeof(GameObject)); 544 | UsableType[] defaultUsableTypes = UsableType.GetUsableTypeArray(componentTypes, gameObjectUsableType); 545 | 546 | List exposedRefTypeList = defaultUsableTypes.ToList (); 547 | exposedRefTypeList.Sort(); 548 | s_ExposedReferenceTypes = exposedRefTypeList.ToArray(); 549 | 550 | UsableType noneType = new UsableType((Type)null); 551 | s_TrackBindingTypes = UsableType.AmalgamateUsableTypes(s_ExposedReferenceTypes, noneType); 552 | 553 | s_BehaviourVariableTypes = UsableType.AmalgamateUsableTypes 554 | ( 555 | s_ExposedReferenceTypes, 556 | new UsableType("int"), 557 | new UsableType("bool"), 558 | new UsableType("float"), 559 | new UsableType("Color"), 560 | new UsableType("double"), 561 | new UsableType("string"), 562 | new UsableType("Vector2"), 563 | new UsableType("Vector3"), 564 | new UsableType("AudioClip"), 565 | new UsableType("AnimationCurve") 566 | ); 567 | List scriptVariableTypeList = s_BehaviourVariableTypes.ToList(); 568 | scriptVariableTypeList.Sort(); 569 | s_BehaviourVariableTypes = scriptVariableTypeList.ToArray(); 570 | } 571 | 572 | void OnGUI () 573 | { 574 | if(s_ComponentTypes == null || s_TrackBindingTypes == null || s_ExposedReferenceTypes == null || s_BehaviourVariableTypes == null) 575 | Init (); 576 | 577 | if (s_ComponentTypes == null || s_TrackBindingTypes == null || s_ExposedReferenceTypes == null || s_BehaviourVariableTypes == null) 578 | { 579 | EditorGUILayout.HelpBox ("Failed to initialise.", MessageType.Error); 580 | return; 581 | } 582 | 583 | m_ScrollViewPos = EditorGUILayout.BeginScrollView (m_ScrollViewPos); 584 | 585 | bool oldShowHelpBoxes = showHelpBoxes; 586 | showHelpBoxes = EditorGUILayout.Toggle (m_ShowHelpBoxesContent, showHelpBoxes); 587 | if (oldShowHelpBoxes != showHelpBoxes) 588 | { 589 | EditorPrefs.SetBool (k_ShowHelpBoxesKey, showHelpBoxes); 590 | EditorGUILayout.Space (); 591 | } 592 | 593 | if (showHelpBoxes) 594 | { 595 | EditorGUILayout.HelpBox("This wizard is used to create the basics of a custom playable for the Timeline. " 596 | + "It will create 4 scripts that you can then edit to complete their functionality. " 597 | + "The purpose is to setup the boilerplate code for you. If you are already familiar " 598 | + "with playables and the Timeline, you may wish to create your own scripts instead.", MessageType.None); 599 | EditorGUILayout.Space(); 600 | } 601 | 602 | EditorGUILayout.Space (); 603 | EditorGUILayout.Space(); 604 | 605 | EditorGUILayout.BeginVertical (GUI.skin.box); 606 | if (showHelpBoxes) 607 | { 608 | EditorGUILayout.HelpBox(m_PlayableNameContent.tooltip, MessageType.Info); 609 | EditorGUILayout.Space(); 610 | } 611 | playableName = EditorGUILayout.TextField (m_PlayableNameContent, playableName); 612 | 613 | bool playableNameNotEmpty = !string.IsNullOrEmpty (playableName); 614 | bool playableNameFormatted = CodeGenerator.IsValidLanguageIndependentIdentifier(playableName); 615 | if (!playableNameNotEmpty || !playableNameFormatted) 616 | { 617 | EditorGUILayout.HelpBox ("The Playable needs a name which starts with a capital letter and contains no spaces or special characters.", MessageType.Error); 618 | } 619 | bool playableNameTooLong = playableName.Length > k_PlayableNameCharLimit; 620 | if (playableNameTooLong) 621 | { 622 | EditorGUILayout.HelpBox ("The Playable needs a name which is fewer than " + k_PlayableNameCharLimit + " characters long.", MessageType.Error); 623 | } 624 | EditorGUILayout.EndVertical (); 625 | 626 | EditorGUILayout.Space(); 627 | EditorGUILayout.Space(); 628 | 629 | EditorGUILayout.BeginVertical(GUI.skin.box); 630 | if(showHelpBoxes) 631 | { 632 | EditorGUILayout.HelpBox(m_StandardBlendPlayableContent.tooltip, MessageType.Info); 633 | EditorGUILayout.Space(); 634 | } 635 | bool oldStandardBlendPlayable = isStandardBlendPlayable; 636 | isStandardBlendPlayable = EditorGUILayout.Toggle (m_StandardBlendPlayableContent, isStandardBlendPlayable); 637 | EditorGUILayout.EndVertical (); 638 | 639 | EditorGUILayout.Space(); 640 | EditorGUILayout.Space(); 641 | 642 | EditorGUILayout.BeginVertical(GUI.skin.box); 643 | if(showHelpBoxes) 644 | { 645 | EditorGUILayout.HelpBox(m_TrackBindingTypeContent.tooltip, MessageType.Info); 646 | EditorGUILayout.Space(); 647 | } 648 | int oldIndex = -1; 649 | if (isStandardBlendPlayable) 650 | { 651 | oldIndex = m_ComponentBindingTypeIndex; 652 | 653 | m_ComponentBindingTypeIndex = EditorGUILayout.Popup (m_TrackBindingTypeContent, m_ComponentBindingTypeIndex, UsableType.GetGUIContentWithSortingArray (s_ComponentTypes)); 654 | trackBinding = s_ComponentTypes[m_ComponentBindingTypeIndex]; 655 | 656 | EditorGUILayout.Space (); 657 | 658 | defaultValuesComponent = EditorGUILayout.ObjectField (m_DefaultValuesComponentContent, defaultValuesComponent, trackBinding.type, true) as Component; 659 | } 660 | else 661 | { 662 | m_TrackBindingTypeIndex = EditorGUILayout.Popup(m_TrackBindingTypeContent, m_TrackBindingTypeIndex, UsableType.GetGUIContentWithSortingArray(s_TrackBindingTypes)); 663 | trackBinding = s_TrackBindingTypes[m_TrackBindingTypeIndex]; 664 | } 665 | EditorGUILayout.EndVertical (); 666 | 667 | bool exposedVariablesNamesValid = true; 668 | bool scriptVariablesNamesValid = true; 669 | bool allUniqueVariableNames = true; 670 | 671 | EditorGUILayout.Space(); 672 | EditorGUILayout.Space(); 673 | 674 | if (isStandardBlendPlayable) 675 | { 676 | StandardBlendPlayablePropertyGUI(oldIndex != m_ComponentBindingTypeIndex || oldStandardBlendPlayable != isStandardBlendPlayable); 677 | } 678 | else 679 | { 680 | exposedVariablesNamesValid = VariableListGUI(exposedReferences, s_ExposedReferenceTypes, m_ExposedReferencesContent, "newExposedReference"); 681 | 682 | EditorGUILayout.Space(); 683 | EditorGUILayout.Space(); 684 | 685 | scriptVariablesNamesValid = VariableListGUI(playableBehaviourVariables, s_BehaviourVariableTypes, m_BehaviourVariablesContent, "newBehaviourVariable"); 686 | 687 | EditorGUILayout.Space(); 688 | EditorGUILayout.Space(); 689 | 690 | allUniqueVariableNames = AllVariablesUniquelyNamed(); 691 | if (!allUniqueVariableNames) 692 | { 693 | EditorGUILayout.HelpBox("Your variables to not have unique names. Make sure all of your Exposed References and Behaviour Variables have unique names.", MessageType.Error); 694 | } 695 | 696 | EditorGUILayout.Space(); 697 | EditorGUILayout.Space(); 698 | 699 | ClipCapsGUI(); 700 | } 701 | 702 | EditorGUILayout.Space(); 703 | EditorGUILayout.Space(); 704 | 705 | /*ClipDefaultsGUI (); 706 | 707 | EditorGUILayout.Space (); 708 | EditorGUILayout.Space ();*/ 709 | 710 | EditorGUILayout.BeginVertical(GUI.skin.box); 711 | if (showHelpBoxes) 712 | { 713 | EditorGUILayout.HelpBox(m_TrackColorContent.tooltip, MessageType.Info); 714 | EditorGUILayout.Space(); 715 | } 716 | trackColor = EditorGUILayout.ColorField(m_TrackColorContent, trackColor); 717 | EditorGUILayout.EndVertical (); 718 | 719 | if (!isStandardBlendPlayable) 720 | { 721 | EditorGUILayout.Space(); 722 | EditorGUILayout.Space(); 723 | 724 | EditorGUILayout.BeginVertical(GUI.skin.box); 725 | if (showHelpBoxes) 726 | { 727 | EditorGUILayout.HelpBox(m_CreateDrawerContent.tooltip, MessageType.Info); 728 | EditorGUILayout.Space(); 729 | } 730 | m_CreateDrawer = EditorGUILayout.Toggle(m_CreateDrawerContent, m_CreateDrawer); 731 | EditorGUILayout.EndVertical (); 732 | } 733 | 734 | EditorGUILayout.Space(); 735 | EditorGUILayout.Space(); 736 | 737 | if (playableNameNotEmpty && playableNameFormatted && allUniqueVariableNames && exposedVariablesNamesValid && scriptVariablesNamesValid && !playableNameTooLong) 738 | { 739 | if (GUILayout.Button("Create", GUILayout.Width(60f))) 740 | { 741 | m_CreateButtonPressed = true; 742 | 743 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 744 | { 745 | standardBlendPlayableProperties[i].CreateSettingDefaultValueString (defaultValuesComponent); 746 | } 747 | 748 | m_CreationError = CreateScripts(); 749 | 750 | if (m_CreationError == CreationError.NoError) 751 | { 752 | Close (); 753 | } 754 | } 755 | } 756 | 757 | EditorGUILayout.Space(); 758 | EditorGUILayout.Space(); 759 | 760 | if (m_CreateButtonPressed) 761 | { 762 | switch (m_CreationError) 763 | { 764 | case CreationError.NoError: 765 | EditorGUILayout.HelpBox ("Playable was successfully created.", MessageType.Info); 766 | break; 767 | case CreationError.PlayableAssetAlreadyExists: 768 | EditorGUILayout.HelpBox ("The type " + playableName + k_TimelineClipAssetSuffix + " already exists, no files were created.", MessageType.Error); 769 | break; 770 | case CreationError.PlayableBehaviourAlreadyExists: 771 | EditorGUILayout.HelpBox ("The type " + playableName + k_TimelineClipBehaviourSuffix + " already exists, no files were created.", MessageType.Error); 772 | break; 773 | case CreationError.PlayableBehaviourMixerAlreadyExists: 774 | EditorGUILayout.HelpBox ("The type " + playableName + k_PlayableBehaviourMixerSuffix + " already exists, no files were created.", MessageType.Error); 775 | break; 776 | case CreationError.TrackAssetAlreadyExists: 777 | EditorGUILayout.HelpBox ("The type " + playableName + k_TrackAssetSuffix + " already exists, no files were created.", MessageType.Error); 778 | break; 779 | case CreationError.PlayableDrawerAlreadyExists: 780 | EditorGUILayout.HelpBox ("The type " + playableName + k_PropertyDrawerSuffix + " already exists, no files were created.", MessageType.Error); 781 | break; 782 | } 783 | } 784 | 785 | if (GUILayout.Button ("Reset", GUILayout.Width (60f))) 786 | { 787 | ResetWindow (); 788 | } 789 | 790 | EditorGUILayout.EndScrollView (); 791 | } 792 | 793 | void StandardBlendPlayablePropertyGUI (bool findNewProperties) 794 | { 795 | if (findNewProperties || m_TrackBindingProperties == null && m_TrackBindingFields == null) 796 | { 797 | m_TrackBindingUsableProperties.Clear (); 798 | 799 | IEnumerable propertyInfos = trackBinding.type.GetProperties (BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.GetProperty); 800 | propertyInfos = propertyInfos.Where (x => IsTypeBlendable(x.PropertyType) || IsTypeAssignable(x.PropertyType)); 801 | propertyInfos = propertyInfos.Where (x => x.CanWrite && x.CanRead); 802 | propertyInfos = propertyInfos.Where (x => HasAllowedName (x)); 803 | // Uncomment the below to stop Obsolete properties being selectable. 804 | //propertyInfos = propertyInfos.Where (x => !Attribute.IsDefined (x, typeof(ObsoleteAttribute))); 805 | m_TrackBindingProperties = propertyInfos.ToArray(); 806 | foreach (PropertyInfo trackBindingProperty in m_TrackBindingProperties) 807 | { 808 | m_TrackBindingUsableProperties.Add (new UsableProperty (trackBindingProperty)); 809 | } 810 | 811 | IEnumerable fieldInfos = trackBinding.type.GetFields (BindingFlags.Instance | BindingFlags.Public); 812 | fieldInfos = fieldInfos.Where(x => IsTypeBlendable(x.FieldType) || IsTypeAssignable(x.FieldType)); 813 | m_TrackBindingFields = fieldInfos.ToArray (); 814 | foreach (FieldInfo trackBindingField in m_TrackBindingFields) 815 | { 816 | m_TrackBindingUsableProperties.Add (new UsableProperty (trackBindingField)); 817 | } 818 | 819 | m_TrackBindingUsableProperties = m_TrackBindingUsableProperties.OrderBy (x => x.name).ToList (); 820 | standardBlendPlayableProperties.Clear (); 821 | } 822 | 823 | EditorGUILayout.BeginVertical (GUI.skin.box); 824 | 825 | if (showHelpBoxes) 826 | { 827 | EditorGUILayout.HelpBox(m_StandardBlendPlayablePropertiesContent.tooltip, MessageType.Info); 828 | EditorGUILayout.Space(); 829 | } 830 | 831 | EditorGUILayout.LabelField(m_StandardBlendPlayablePropertiesContent); 832 | 833 | int indexToRemove = -1; 834 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 835 | { 836 | if (standardBlendPlayableProperties[i].GUI(m_TrackBindingUsableProperties)) 837 | indexToRemove = i; 838 | } 839 | if (indexToRemove != -1) 840 | standardBlendPlayableProperties.RemoveAt(indexToRemove); 841 | 842 | if (GUILayout.Button("Add", GUILayout.Width(40f))) 843 | standardBlendPlayableProperties.Add(m_TrackBindingUsableProperties[0].GetDuplicate ()); 844 | 845 | if (standardBlendPlayableProperties.Any(IsObsolete)) 846 | EditorGUILayout.HelpBox ("One or more of your chosen properties are marked 'Obsolete'. Consider changing them to avoid deprecation with future versions of Unity.", MessageType.Warning); 847 | 848 | EditorGUILayout.EndVertical (); 849 | } 850 | 851 | static bool IsTypeBlendable (Type type) 852 | { 853 | for (int i = 0; i < s_BlendableTypes.Length; i++) 854 | { 855 | if (type == s_BlendableTypes[i]) 856 | return true; 857 | } 858 | return false; 859 | } 860 | 861 | static bool IsTypeAssignable (Type type) 862 | { 863 | for (int i = 0; i < s_AssignableTypes.Length; i++) 864 | { 865 | if (type == s_AssignableTypes[i] || type.IsEnum) 866 | return true; 867 | } 868 | return false; 869 | } 870 | 871 | static bool HasAllowedName (PropertyInfo propertyInfo) 872 | { 873 | for (int i = 0; i < s_DisallowedPropertyNames.Length; i++) 874 | { 875 | if (propertyInfo.Name == s_DisallowedPropertyNames[i]) 876 | return false; 877 | } 878 | return true; 879 | } 880 | 881 | static bool IsObsolete (UsableProperty usableProperty) 882 | { 883 | if (usableProperty.usablePropertyType == UsableProperty.UsablePropertyType.Field) 884 | return Attribute.IsDefined (usableProperty.fieldInfo, typeof(ObsoleteAttribute)); 885 | return Attribute.IsDefined (usableProperty.propertyInfo, typeof(ObsoleteAttribute)); 886 | } 887 | 888 | bool VariableListGUI (List variables, UsableType[] usableTypes, GUIContent guiContent, string newName) 889 | { 890 | EditorGUILayout.BeginVertical(GUI.skin.box); 891 | 892 | if (showHelpBoxes) 893 | { 894 | EditorGUILayout.HelpBox(guiContent.tooltip, MessageType.Info); 895 | EditorGUILayout.Space(); 896 | } 897 | 898 | EditorGUILayout.LabelField(guiContent); 899 | 900 | int indexToRemove = -1; 901 | bool allNamesValid = true; 902 | for (int i = 0; i < variables.Count; i++) 903 | { 904 | if (variables[i].GUI(usableTypes)) 905 | indexToRemove = i; 906 | 907 | if (!CodeGenerator.IsValidLanguageIndependentIdentifier(variables[i].name)) 908 | { 909 | allNamesValid = false; 910 | } 911 | } 912 | 913 | if (indexToRemove != -1) 914 | variables.RemoveAt(indexToRemove); 915 | 916 | if (GUILayout.Button("Add", GUILayout.Width(40f))) 917 | variables.Add(new Variable(newName, usableTypes[0])); 918 | 919 | if (!allNamesValid) 920 | EditorGUILayout.HelpBox("One of the variables has an invalid character, make sure they don't contain any spaces or special characters.", MessageType.Error); 921 | 922 | EditorGUILayout.EndVertical(); 923 | 924 | return allNamesValid; 925 | } 926 | 927 | bool AllVariablesUniquelyNamed () 928 | { 929 | for (int i = 0; i < exposedReferences.Count; i++) 930 | { 931 | string exposedRefName = exposedReferences[i].name; 932 | 933 | for (int j = 0; j < exposedReferences.Count; j++) 934 | { 935 | if (i != j && exposedRefName == exposedReferences[j].name) 936 | return false; 937 | } 938 | 939 | for (int j = 0; j < playableBehaviourVariables.Count; j++) 940 | { 941 | if (exposedRefName == playableBehaviourVariables[j].name) 942 | return false; 943 | } 944 | } 945 | 946 | for (int i = 0; i < playableBehaviourVariables.Count; i++) 947 | { 948 | string scriptPlayableVariableName = playableBehaviourVariables[i].name; 949 | 950 | for (int j = 0; j < exposedReferences.Count; j++) 951 | { 952 | if (scriptPlayableVariableName == exposedReferences[j].name) 953 | return false; 954 | } 955 | 956 | for (int j = 0; j < playableBehaviourVariables.Count; j++) 957 | { 958 | if (i != j && scriptPlayableVariableName == playableBehaviourVariables[j].name) 959 | return false; 960 | } 961 | } 962 | return true; 963 | } 964 | 965 | void ClipCapsGUI () 966 | { 967 | EditorGUILayout.BeginVertical (GUI.skin.box); 968 | 969 | if (showHelpBoxes) 970 | { 971 | EditorGUILayout.HelpBox(m_ClipCapsContent.tooltip, MessageType.Info); 972 | EditorGUILayout.Space(); 973 | } 974 | 975 | EditorGUILayout.LabelField (m_ClipCapsContent); 976 | 977 | bool isLooping = (clipCaps & ClipCaps.Looping) == ClipCaps.Looping; 978 | bool isExtrapolation = (clipCaps & ClipCaps.Extrapolation) == ClipCaps.Extrapolation; 979 | bool isClipIn = (clipCaps & ClipCaps.ClipIn) == ClipCaps.ClipIn; 980 | bool isSpeedMultiplier = (clipCaps & ClipCaps.SpeedMultiplier) == ClipCaps.SpeedMultiplier; 981 | bool isBlending = (clipCaps & ClipCaps.Blending) == ClipCaps.Blending; 982 | 983 | bool isNone = !isLooping && !isExtrapolation && !isClipIn && !isSpeedMultiplier && !isBlending; 984 | bool isAll = isLooping && isExtrapolation && isClipIn && isSpeedMultiplier && isBlending; 985 | 986 | EditorGUI.BeginChangeCheck (); 987 | isNone = EditorGUILayout.ToggleLeft (m_CCNoneContent, isNone); 988 | if (EditorGUI.EndChangeCheck ()) 989 | { 990 | if (isNone) 991 | { 992 | isLooping = false; 993 | isExtrapolation = false; 994 | isClipIn = false; 995 | isSpeedMultiplier = false; 996 | isBlending = false; 997 | isAll = false; 998 | } 999 | } 1000 | 1001 | EditorGUI.BeginChangeCheck (); 1002 | isLooping = EditorGUILayout.ToggleLeft (m_CCLoopingContent, isLooping); 1003 | isExtrapolation = EditorGUILayout.ToggleLeft (m_CCExtrapolationContent, isExtrapolation); 1004 | isClipIn = EditorGUILayout.ToggleLeft (m_CCClipInContent, isClipIn); 1005 | isSpeedMultiplier = EditorGUILayout.ToggleLeft (m_CCSpeedMultiplierContent, isSpeedMultiplier); 1006 | isBlending = EditorGUILayout.ToggleLeft (m_CCBlendingContent, isBlending); 1007 | if (EditorGUI.EndChangeCheck ()) 1008 | { 1009 | isNone = !isLooping && !isExtrapolation && !isClipIn && !isSpeedMultiplier && !isBlending; 1010 | isAll = isLooping && isExtrapolation && isClipIn && isSpeedMultiplier && isBlending; 1011 | } 1012 | 1013 | EditorGUI.BeginChangeCheck (); 1014 | isAll = EditorGUILayout.ToggleLeft (m_CCAllContent, isAll); 1015 | if (EditorGUI.EndChangeCheck ()) 1016 | { 1017 | if (isAll) 1018 | { 1019 | isNone = false; 1020 | isLooping = true; 1021 | isExtrapolation = true; 1022 | isClipIn = true; 1023 | isSpeedMultiplier = true; 1024 | isBlending = true; 1025 | } 1026 | } 1027 | 1028 | EditorGUILayout.EndVertical(); 1029 | 1030 | clipCaps = ClipCaps.None; 1031 | 1032 | if (isNone) 1033 | return; 1034 | 1035 | if (isAll) 1036 | { 1037 | clipCaps = ClipCaps.All; 1038 | return; 1039 | } 1040 | 1041 | if (isLooping) 1042 | clipCaps |= ClipCaps.Looping; 1043 | 1044 | if (isExtrapolation) 1045 | clipCaps |= ClipCaps.Extrapolation; 1046 | 1047 | if (isClipIn) 1048 | clipCaps |= ClipCaps.ClipIn; 1049 | 1050 | if (isSpeedMultiplier) 1051 | clipCaps |= ClipCaps.SpeedMultiplier; 1052 | 1053 | if (isBlending) 1054 | clipCaps |= ClipCaps.Blending; 1055 | } 1056 | 1057 | /*void ClipDefaultsGUI () 1058 | { 1059 | EditorGUILayout.BeginVertical (GUI.skin.box); 1060 | 1061 | setClipDefaults = EditorGUILayout.Toggle (m_SetClipDefaultsContent, setClipDefaults); 1062 | 1063 | if (!setClipDefaults) 1064 | { 1065 | EditorGUILayout.EndVertical (); 1066 | return; 1067 | } 1068 | 1069 | if (showHelpBoxes) 1070 | { 1071 | EditorGUILayout.HelpBox (m_ClipDefaultsContent.tooltip, MessageType.Info); 1072 | } 1073 | 1074 | EditorGUILayout.LabelField (m_ClipDefaultsContent); 1075 | 1076 | EditorGUILayout.Space (); 1077 | 1078 | EditorGUILayout.LabelField (m_CDClipTimingContent); 1079 | EditorGUI.indentLevel++; 1080 | clipDefaultDurationSeconds = EditorGUILayout.FloatField(m_CDDurationContent, clipDefaultDurationSeconds); 1081 | 1082 | EditorGUILayout.Space (); 1083 | 1084 | clipDefaultEaseInSeconds = EditorGUILayout.FloatField(m_CDEaseInContent, clipDefaultEaseInSeconds); 1085 | clipDefaultEaseOutSeconds = EditorGUILayout.FloatField (m_CDEaseOutContent, clipDefaultEaseOutSeconds); 1086 | 1087 | if (isStandardBlendPlayable) 1088 | { 1089 | EditorGUILayout.EndVertical(); 1090 | return; 1091 | } 1092 | 1093 | EditorGUILayout.Space(); 1094 | 1095 | clipDefaultClipInSeconds = EditorGUILayout.FloatField(m_CDClipInContent, clipDefaultClipInSeconds); 1096 | 1097 | EditorGUILayout.Space(); 1098 | 1099 | clipDefaultSpeedMultiplier = EditorGUILayout.FloatField(m_CDSpeedMultiplierContent, clipDefaultSpeedMultiplier); 1100 | EditorGUI.indentLevel--; 1101 | 1102 | EditorGUILayout.EndVertical(); 1103 | }*/ 1104 | 1105 | CreationError CreateScripts () 1106 | { 1107 | if (ScriptAlreadyExists(playableName + k_TimelineClipAssetSuffix)) 1108 | return CreationError.PlayableAssetAlreadyExists; 1109 | 1110 | if (ScriptAlreadyExists(playableName + k_TimelineClipBehaviourSuffix)) 1111 | return CreationError.PlayableBehaviourAlreadyExists; 1112 | 1113 | if (ScriptAlreadyExists(playableName + k_PlayableBehaviourMixerSuffix)) 1114 | return CreationError.PlayableBehaviourMixerAlreadyExists; 1115 | 1116 | if (ScriptAlreadyExists(playableName + k_TrackAssetSuffix)) 1117 | return CreationError.TrackAssetAlreadyExists; 1118 | 1119 | if (m_CreateDrawer && ScriptAlreadyExists(playableName + k_PropertyDrawerSuffix)) 1120 | return CreationError.PlayableDrawerAlreadyExists; 1121 | 1122 | AssetDatabase.CreateFolder ("Assets", playableName); 1123 | 1124 | if (isStandardBlendPlayable) 1125 | { 1126 | CreateScript (playableName + k_TimelineClipAssetSuffix, StandardBlendPlayableAsset()); 1127 | CreateScript (playableName + k_TimelineClipBehaviourSuffix, StandardBlendPlayableBehaviour ()); 1128 | CreateScript (playableName + k_PlayableBehaviourMixerSuffix, StandardBlendPlayableBehaviourMixer ()); 1129 | CreateScript (playableName + k_TrackAssetSuffix, StandardBlendTrackAssetScript ()); 1130 | 1131 | AssetDatabase.CreateFolder ("Assets/" + playableName, "Editor"); 1132 | 1133 | string path = Application.dataPath + "/" + playableName + "/Editor/" + playableName + k_PropertyDrawerSuffix + ".cs"; 1134 | using (StreamWriter writer = File.CreateText (path)) 1135 | { 1136 | writer.Write (StandardBlendPlayableDrawer ()); 1137 | } 1138 | } 1139 | else 1140 | { 1141 | CreateScript(playableName + k_TimelineClipAssetSuffix, PlayableAsset()); 1142 | CreateScript(playableName + k_TimelineClipBehaviourSuffix, PlayableBehaviour()); 1143 | CreateScript(playableName + k_PlayableBehaviourMixerSuffix, PlayableBehaviourMixer()); 1144 | CreateScript(playableName + k_TrackAssetSuffix, TrackAssetScript()); 1145 | 1146 | if (m_CreateDrawer) 1147 | { 1148 | AssetDatabase.CreateFolder("Assets/" + playableName, "Editor"); 1149 | 1150 | string path = Application.dataPath + "/" + playableName + "/Editor/" + playableName + k_PropertyDrawerSuffix + ".cs"; 1151 | using (StreamWriter writer = File.CreateText(path)) 1152 | { 1153 | writer.Write(PlayableDrawer()); 1154 | } 1155 | } 1156 | } 1157 | 1158 | AssetDatabase.SaveAssets (); 1159 | AssetDatabase.Refresh (); 1160 | 1161 | return CreationError.NoError; 1162 | } 1163 | 1164 | static bool ScriptAlreadyExists(string scriptName) 1165 | { 1166 | string[] guids = AssetDatabase.FindAssets(scriptName); 1167 | 1168 | if (guids.Length == 0) 1169 | return false; 1170 | 1171 | for (int i = 0; i < guids.Length; i++) 1172 | { 1173 | string path = AssetDatabase.GUIDToAssetPath(guids[i]); 1174 | Type assetType = AssetDatabase.GetMainAssetTypeAtPath(path); 1175 | if (assetType == typeof(MonoScript)) 1176 | return true; 1177 | } 1178 | 1179 | return false; 1180 | } 1181 | 1182 | void CreateScript (string fileName, string content) 1183 | { 1184 | string path = Application.dataPath + "/" + playableName + "/" + fileName + ".cs"; 1185 | using (StreamWriter writer = File.CreateText (path)) 1186 | writer.Write (content); 1187 | } 1188 | 1189 | void ResetWindow () 1190 | { 1191 | playableName = ""; 1192 | isStandardBlendPlayable = false; 1193 | trackBinding = s_TrackBindingTypes[0]; 1194 | defaultValuesComponent = null; 1195 | exposedReferences = new List(); 1196 | playableBehaviourVariables = new List(); 1197 | standardBlendPlayableProperties = new List(); 1198 | clipCaps = ClipCaps.None; 1199 | /*setClipDefaults = false; 1200 | clipDefaultDurationSeconds = 5f; 1201 | clipDefaultEaseInSeconds = 0f; 1202 | clipDefaultEaseOutSeconds = 0f; 1203 | clipDefaultClipInSeconds = 0f; 1204 | clipDefaultSpeedMultiplier = 1f;*/ 1205 | trackColor = new Color(0.855f, 0.8623f, 0.870f); 1206 | 1207 | m_TrackBindingTypeIndex = 0; 1208 | m_ComponentBindingTypeIndex = 0; 1209 | m_TrackBindingProperties = null; 1210 | m_TrackBindingFields = null; 1211 | m_TrackBindingUsableProperties = null; 1212 | m_CreateDrawer = false; 1213 | } 1214 | 1215 | string TrackAssetScript () 1216 | { 1217 | return 1218 | "using UnityEngine;\n" + 1219 | "using UnityEngine.Playables;\n" + 1220 | "using UnityEngine.Timeline;\n" + 1221 | AdditionalNamespacesToString() + 1222 | "\n" + 1223 | "[TrackColor(" + trackColor.r + "f, " + trackColor.g + "f, " + trackColor.b + "f)]\n" + 1224 | "[TrackClipType(typeof(" + playableName + k_TimelineClipAssetSuffix + "))]\n" + 1225 | TrackBindingToString () + 1226 | "public class " + playableName + k_TrackAssetSuffix + " : TrackAsset\n" + 1227 | "{\n" + 1228 | k_Tab + "public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)\n" + 1229 | k_Tab + "{\n" + 1230 | k_Tab + k_Tab + "return ScriptPlayable<" + playableName + k_PlayableBehaviourMixerSuffix + ">.Create (graph, inputCount);\n" + 1231 | k_Tab + "}\n" + 1232 | "}\n"; 1233 | } 1234 | 1235 | string PlayableAsset () 1236 | { 1237 | return 1238 | "using System;\n" + 1239 | "using UnityEngine;\n" + 1240 | "using UnityEngine.Playables;\n" + 1241 | "using UnityEngine.Timeline;\n" + 1242 | AdditionalNamespacesToString() + 1243 | "\n" + 1244 | "[Serializable]\n" + 1245 | "public class " + playableName + k_TimelineClipAssetSuffix + " : PlayableAsset, ITimelineClipAsset\n" + 1246 | "{\n" + 1247 | k_Tab + "public " + playableName + k_TimelineClipBehaviourSuffix + " template = new " + playableName + k_TimelineClipBehaviourSuffix + " ();\n" + 1248 | ExposedReferencesToString () + 1249 | "\n" + 1250 | k_Tab + "public ClipCaps clipCaps\n" + 1251 | k_Tab + "{\n" + 1252 | k_Tab + k_Tab + "get { return " + ClipCapsToString () + "; }\n" + 1253 | k_Tab + "}\n" + 1254 | "\n" + 1255 | k_Tab + "public override Playable CreatePlayable (PlayableGraph graph, GameObject owner)\n" + 1256 | k_Tab + "{\n" + 1257 | k_Tab + k_Tab + "var playable = ScriptPlayable<" + playableName + k_TimelineClipBehaviourSuffix + ">.Create (graph, template);\n" + 1258 | ExposedReferencesResolvingToString () + 1259 | k_Tab + k_Tab + "return playable;\n" + 1260 | k_Tab + "}\n" + 1261 | "}\n"; 1262 | } 1263 | 1264 | string PlayableBehaviour () 1265 | { 1266 | return 1267 | "using System;\n" + 1268 | "using UnityEngine;\n" + 1269 | "using UnityEngine.Playables;\n" + 1270 | "using UnityEngine.Timeline;\n" + 1271 | AdditionalNamespacesToString() + 1272 | "\n" + 1273 | "[Serializable]\n" + 1274 | "public class " + playableName + k_TimelineClipBehaviourSuffix + " : PlayableBehaviour\n" + 1275 | "{\n" + 1276 | ExposedReferencesAsScriptVariablesToString () + 1277 | PlayableBehaviourVariablesToString () + 1278 | "\n" + 1279 | k_Tab + "public override void OnPlayableCreate (Playable playable)\n" + 1280 | k_Tab + "{\n" + 1281 | k_Tab + k_Tab + "\n" + 1282 | k_Tab + "}\n" + 1283 | "}\n"; 1284 | } 1285 | 1286 | string PlayableBehaviourMixer () 1287 | { 1288 | return 1289 | "using System;\n" + 1290 | "using UnityEngine;\n" + 1291 | "using UnityEngine.Playables;\n" + 1292 | "using UnityEngine.Timeline;\n" + 1293 | AdditionalNamespacesToString() + 1294 | "\n" + 1295 | "public class " + playableName + k_PlayableBehaviourMixerSuffix + " : PlayableBehaviour\n" + 1296 | "{\n" + 1297 | k_Tab + "// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties.\n" + 1298 | k_Tab + "public override void ProcessFrame(Playable playable, FrameData info, object playerData)\n" + 1299 | k_Tab + "{\n" + 1300 | MixerTrackBindingLocalVariableToString () + 1301 | k_Tab + k_Tab + "int inputCount = playable.GetInputCount ();\n" + 1302 | "\n" + 1303 | k_Tab + k_Tab + "for (int i = 0; i < inputCount; i++)\n" + 1304 | k_Tab + k_Tab + "{\n" + 1305 | k_Tab + k_Tab + k_Tab + "float inputWeight = playable.GetInputWeight(i);\n" + 1306 | k_Tab + k_Tab + k_Tab + "ScriptPlayable<" + playableName + k_TimelineClipBehaviourSuffix + "> inputPlayable = (ScriptPlayable<" + playableName + k_TimelineClipBehaviourSuffix + ">)playable.GetInput(i);\n" + 1307 | k_Tab + k_Tab + k_Tab + playableName + k_TimelineClipBehaviourSuffix + " input = inputPlayable.GetBehaviour ();\n" + 1308 | k_Tab + k_Tab + k_Tab + "\n" + 1309 | k_Tab + k_Tab + k_Tab + "// Use the above variables to process each frame of this playable.\n" + 1310 | k_Tab + k_Tab + k_Tab + "\n" + 1311 | k_Tab + k_Tab + "}\n" + 1312 | k_Tab + "}\n" + 1313 | "}\n"; 1314 | } 1315 | 1316 | string PlayableDrawer () 1317 | { 1318 | return 1319 | "using UnityEditor;\n" + 1320 | "using UnityEngine;\n" + 1321 | "\n" + 1322 | "[CustomPropertyDrawer(typeof(" + playableName + k_TimelineClipBehaviourSuffix + "))]\n" + 1323 | "public class " + playableName + k_PropertyDrawerSuffix + " : PropertyDrawer\n" + 1324 | "{\n" + 1325 | k_Tab + "public override float GetPropertyHeight (SerializedProperty property, GUIContent label)\n" + 1326 | k_Tab + "{\n" + 1327 | k_Tab + k_Tab + "int fieldCount = " + playableBehaviourVariables.Count +";\n" + 1328 | k_Tab + k_Tab + "return fieldCount * EditorGUIUtility.singleLineHeight;\n" + 1329 | k_Tab + "}\n" + 1330 | "\n" + 1331 | k_Tab + "public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)\n" + 1332 | k_Tab + "{\n" + 1333 | ScriptVariablesAsSerializedPropAssignmentToString () + 1334 | "\n" + 1335 | k_Tab + k_Tab + "Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);\n" + 1336 | ScriptVariablesAsSerializedPropGUIToString () + 1337 | k_Tab + "}\n" + 1338 | "}\n"; 1339 | } 1340 | 1341 | string TrackBindingToString () 1342 | { 1343 | if (m_TrackBindingTypeIndex != 0) 1344 | return "[TrackBindingType(typeof(" + trackBinding.name + "))]\n"; 1345 | return ""; 1346 | } 1347 | 1348 | string AdditionalNamespacesToString () 1349 | { 1350 | UsableType[] exposedReferenceTypes = Variable.GetUsableTypesFromVariableArray (exposedReferences.ToArray ()); 1351 | UsableType[] behaviourVariableTypes = Variable.GetUsableTypesFromVariableArray (playableBehaviourVariables.ToArray ()); 1352 | UsableType[] allUsedTypes = new UsableType[exposedReferenceTypes.Length + behaviourVariableTypes.Length + 1]; 1353 | for (int i = 0; i < exposedReferenceTypes.Length; i++) 1354 | { 1355 | allUsedTypes[i] = exposedReferenceTypes[i]; 1356 | } 1357 | for (int i = 0; i < behaviourVariableTypes.Length; i++) 1358 | { 1359 | allUsedTypes[i + exposedReferenceTypes.Length] = behaviourVariableTypes[i]; 1360 | } 1361 | allUsedTypes[allUsedTypes.Length - 1] = trackBinding; 1362 | 1363 | string[] distinctNamespaces = UsableType.GetDistinctAdditionalNamespaces (allUsedTypes).Where (x => !string.IsNullOrEmpty (x)).ToArray (); 1364 | string returnVal = ""; 1365 | for (int i = 0; i < distinctNamespaces.Length; i++) 1366 | { 1367 | returnVal += "using " + distinctNamespaces[i] + ";\n"; 1368 | } 1369 | return returnVal; 1370 | } 1371 | 1372 | string ExposedReferencesToString () 1373 | { 1374 | string expRefText = ""; 1375 | foreach (var expRef in exposedReferences) 1376 | expRefText += k_Tab + "public ExposedReference<" + expRef.usableType.name + "> " + expRef.name + ";\n"; 1377 | return expRefText; 1378 | } 1379 | 1380 | string ExposedReferencesResolvingToString () 1381 | { 1382 | string returnVal = ""; 1383 | returnVal += k_Tab + k_Tab + playableName + k_TimelineClipBehaviourSuffix + " clone = playable.GetBehaviour ();\n"; 1384 | for (int i = 0; i < exposedReferences.Count; i++) 1385 | { 1386 | returnVal += k_Tab + k_Tab + "clone." + exposedReferences[i].name + " = " + exposedReferences[i].name + ".Resolve (graph.GetResolver ());\n"; 1387 | } 1388 | return returnVal; 1389 | } 1390 | 1391 | /*string OnCreateFunctionToString () 1392 | { 1393 | if (!setClipDefaults) 1394 | return ""; 1395 | 1396 | string returnVal = "\n"; 1397 | returnVal += k_Tab + "public override void OnCreate ()\n"; 1398 | returnVal += k_Tab + "{\n"; 1399 | returnVal += k_Tab + k_Tab + "owner.duration = " + clipDefaultDurationSeconds + ";\n"; 1400 | returnVal += k_Tab + k_Tab + "owner.easeInDuration = " + clipDefaultEaseInSeconds + ";\n"; 1401 | returnVal += k_Tab + k_Tab + "owner.easeOutDuration = " + clipDefaultEaseOutSeconds + ";\n"; 1402 | returnVal += k_Tab + k_Tab + "owner.clipIn = " + clipDefaultClipInSeconds + ";\n"; 1403 | returnVal += k_Tab + k_Tab + "owner.timeScale = " + clipDefaultSpeedMultiplier + ";\n"; 1404 | returnVal += k_Tab + "}\n"; 1405 | return returnVal; 1406 | }*/ 1407 | 1408 | string ClipCapsToString () 1409 | { 1410 | string message = clipCaps.ToString (); 1411 | string[] splits = message.Split (' '); 1412 | 1413 | for (int i = 0; i < splits.Length; i++) 1414 | { 1415 | if (splits[i][splits[i].Length - 1] == ',') 1416 | splits[i] = splits[i].Substring (0, splits[i].Length - 1); 1417 | } 1418 | 1419 | string returnVal = ""; 1420 | 1421 | for (int i = 0; i < splits.Length; i++) 1422 | { 1423 | returnVal += "ClipCaps." + splits[i]; 1424 | 1425 | if (i < splits.Length - 1) 1426 | returnVal += " | "; 1427 | } 1428 | 1429 | return returnVal; 1430 | } 1431 | 1432 | string ExposedReferencesAsScriptVariablesToString () 1433 | { 1434 | string returnVal = ""; 1435 | for (int i = 0; i < exposedReferences.Count; i++) 1436 | { 1437 | returnVal += k_Tab + "public " + exposedReferences[i].usableType.name + " " + exposedReferences[i].name + ";\n"; 1438 | } 1439 | return returnVal; 1440 | } 1441 | 1442 | string PlayableBehaviourVariablesToString () 1443 | { 1444 | string returnVal = ""; 1445 | for (int i = 0; i < playableBehaviourVariables.Count; i++) 1446 | { 1447 | returnVal += k_Tab + "public " + playableBehaviourVariables[i].usableType.name + " " + playableBehaviourVariables[i].name + ";\n"; 1448 | } 1449 | return returnVal; 1450 | } 1451 | 1452 | string MixerTrackBindingLocalVariableToString () 1453 | { 1454 | if (m_TrackBindingTypeIndex != 0) 1455 | return 1456 | k_Tab + k_Tab + trackBinding.name + " trackBinding = playerData as " + trackBinding.name + ";\n\n" + 1457 | k_Tab + k_Tab + "if (!trackBinding)\n" + 1458 | k_Tab + k_Tab + k_Tab + "return;\n" + 1459 | "\n"; 1460 | return ""; 1461 | } 1462 | 1463 | string ScriptVariablesAsSerializedPropAssignmentToString () 1464 | { 1465 | string returnVal = ""; 1466 | for (int i = 0; i < playableBehaviourVariables.Count; i++) 1467 | { 1468 | returnVal += k_Tab + k_Tab + "SerializedProperty " + playableBehaviourVariables[i].name + "Prop = property.FindPropertyRelative(\"" + playableBehaviourVariables[i].name + "\");\n"; 1469 | } 1470 | return returnVal; 1471 | } 1472 | 1473 | string ScriptVariablesAsSerializedPropGUIToString () 1474 | { 1475 | string returnVal = ""; 1476 | for (int i = 0; i < playableBehaviourVariables.Count; i++) 1477 | { 1478 | returnVal += k_Tab + k_Tab + "EditorGUI.PropertyField(singleFieldRect, " + playableBehaviourVariables[i].name + "Prop);\n"; 1479 | 1480 | if (i < playableBehaviourVariables.Count - 1) 1481 | { 1482 | returnVal += "\n"; 1483 | returnVal += k_Tab + k_Tab + "singleFieldRect.y += EditorGUIUtility.singleLineHeight;\n"; 1484 | } 1485 | } 1486 | return returnVal; 1487 | } 1488 | 1489 | string StandardBlendPlayableAsset () 1490 | { 1491 | return 1492 | "using System;\n" + 1493 | "using UnityEngine;\n" + 1494 | "using UnityEngine.Playables;\n" + 1495 | "using UnityEngine.Timeline;\n" + 1496 | "\n" + 1497 | "[Serializable]\n" + 1498 | "public class " + playableName + k_TimelineClipAssetSuffix + " : PlayableAsset, ITimelineClipAsset\n" + 1499 | "{\n" + 1500 | k_Tab + "public " + playableName + k_TimelineClipBehaviourSuffix + " template = new " + playableName + k_TimelineClipBehaviourSuffix + " ();\n" + 1501 | "\n" + 1502 | k_Tab + "public ClipCaps clipCaps\n" + 1503 | k_Tab + "{\n" + 1504 | k_Tab + k_Tab + "get { return ClipCaps.Blending; }\n" + 1505 | k_Tab + "}\n" + 1506 | "\n" + 1507 | k_Tab + "public override Playable CreatePlayable (PlayableGraph graph, GameObject owner)\n" + 1508 | k_Tab + "{\n" + 1509 | k_Tab + k_Tab + "var playable = ScriptPlayable<" + playableName + k_TimelineClipBehaviourSuffix + ">.Create (graph, template);\n" + 1510 | k_Tab + k_Tab + "return playable;\n" + 1511 | k_Tab + "}\n" + 1512 | "}\n"; 1513 | } 1514 | 1515 | string StandardBlendPlayableBehaviour () 1516 | { 1517 | return 1518 | "using System;\n" + 1519 | "using UnityEngine;\n" + 1520 | "using UnityEngine.Playables;\n" + 1521 | "using UnityEngine.Timeline;\n" + 1522 | AdditionalNamespacesToString() + 1523 | "\n" + 1524 | "[Serializable]\n" + 1525 | "public class " + playableName + k_TimelineClipBehaviourSuffix + " : PlayableBehaviour\n" + 1526 | "{\n" + 1527 | StandardBlendScriptPlayablePropertiesToString () + 1528 | "}\n"; 1529 | } 1530 | 1531 | string StandardBlendPlayableBehaviourMixer () 1532 | { 1533 | return 1534 | "using System;\n" + 1535 | "using UnityEngine;\n" + 1536 | "using UnityEngine.Playables;\n" + 1537 | "using UnityEngine.Timeline;\n" + 1538 | AdditionalNamespacesToString() + 1539 | "\n" + 1540 | "public class " + playableName + k_PlayableBehaviourMixerSuffix + " : PlayableBehaviour\n" + 1541 | "{\n" + 1542 | StandardBlendTrackBindingPropertiesDefaultsDeclarationToString () + 1543 | "\n" + 1544 | StandardBlendTrackBindingPropertiesBlendedDeclarationToString () + 1545 | "\n" + 1546 | k_Tab + trackBinding.name + " m_TrackBinding;\n" + 1547 | "\n" + 1548 | k_Tab + "public override void ProcessFrame(Playable playable, FrameData info, object playerData)\n" + 1549 | k_Tab + "{\n" + 1550 | k_Tab + k_Tab + "m_TrackBinding = playerData as " + trackBinding.name + ";\n" + 1551 | "\n" + 1552 | k_Tab + k_Tab + "if (m_TrackBinding == null)\n" + 1553 | k_Tab + k_Tab + k_Tab + "return;\n" + 1554 | "\n" + 1555 | StandardBlendTrackBindingPropertiesDefaultsAssignmentToString () + 1556 | "\n" + 1557 | k_Tab + k_Tab + "int inputCount = playable.GetInputCount ();\n" + 1558 | "\n" + 1559 | StandardBlendBlendedVariablesCreationToString () + 1560 | k_Tab + k_Tab + "float totalWeight = 0f;\n" + 1561 | k_Tab + k_Tab + "float greatestWeight = 0f;\n" + 1562 | StandardBlendPlayableCurrentInputsDeclarationToString () + 1563 | "\n" + 1564 | k_Tab + k_Tab + "for (int i = 0; i < inputCount; i++)\n" + 1565 | k_Tab + k_Tab + "{\n" + 1566 | k_Tab + k_Tab + k_Tab + "float inputWeight = playable.GetInputWeight(i);\n" + 1567 | k_Tab + k_Tab + k_Tab + "ScriptPlayable<" + playableName + k_TimelineClipBehaviourSuffix + "> inputPlayable = (ScriptPlayable<" + playableName + k_TimelineClipBehaviourSuffix + ">)playable.GetInput(i);\n" + 1568 | k_Tab + k_Tab + k_Tab + playableName + k_TimelineClipBehaviourSuffix + " input = inputPlayable.GetBehaviour ();\n" + 1569 | k_Tab + k_Tab + k_Tab + "\n" + 1570 | StandardBlendBlendedVariablesWeightedIncrementationToString () + 1571 | k_Tab + k_Tab + k_Tab + "totalWeight += inputWeight;\n" + 1572 | "\n" + 1573 | StandardBlendAssignableVariablesAssignedBasedOnGreatestWeightToString () + 1574 | StandardBlendPlayableCurrentInputIterationToString () + 1575 | k_Tab + k_Tab + "}\n" + 1576 | StandardBlendTrackBindingPropertiesBlendedAssignmentToString () + 1577 | StandardBlendTrackBindingPropertiesAssignableAssignmentToString () + 1578 | k_Tab + "}\n" + 1579 | "}\n"; 1580 | } 1581 | 1582 | string StandardBlendTrackAssetScript () 1583 | { 1584 | return 1585 | "using UnityEngine;\n" + 1586 | "using UnityEngine.Playables;\n" + 1587 | "using UnityEngine.Timeline;\n" + 1588 | "using System.Collections.Generic;\n" + 1589 | AdditionalNamespacesToString() + 1590 | "\n" + 1591 | "[TrackColor(" + trackColor.r + "f, " + trackColor.g + "f, " + trackColor.b + "f)]\n" + 1592 | "[TrackClipType(typeof(" + playableName + k_TimelineClipAssetSuffix + "))]\n" + 1593 | StandardBlendComponentBindingToString () + 1594 | "public class " + playableName + k_TrackAssetSuffix + " : TrackAsset\n" + 1595 | "{\n" + 1596 | k_Tab + "public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)\n" + 1597 | k_Tab + "{\n" + 1598 | k_Tab + k_Tab + "return ScriptPlayable<" + playableName + k_PlayableBehaviourMixerSuffix + ">.Create (graph, inputCount);\n" + 1599 | k_Tab + "}\n" + 1600 | "\n" + 1601 | k_Tab + "// Please note this assumes only one component of type " + trackBinding.name + " on the same gameobject.\n" + 1602 | k_Tab + "public override void GatherProperties (PlayableDirector director, IPropertyCollector driver)\n" + 1603 | k_Tab + "{\n" + 1604 | "#if UNITY_EDITOR\n" + 1605 | k_Tab + k_Tab + trackBinding.name + " trackBinding = director.GetGenericBinding(this) as " + trackBinding.name + ";\n" + 1606 | k_Tab + k_Tab + "if (trackBinding == null)\n" + 1607 | k_Tab + k_Tab + k_Tab + "return;\n" + 1608 | "\n" + 1609 | //k_Tab + k_Tab + "var serializedObject = new UnityEditor.SerializedObject (trackBinding);\n" + 1610 | //k_Tab + k_Tab + "var iterator = serializedObject.GetIterator();\n" + 1611 | //k_Tab + k_Tab + "while (iterator.NextVisible(true))\n" + 1612 | //k_Tab + k_Tab + "{\n" + 1613 | //k_Tab + k_Tab + k_Tab + "if (iterator.hasVisibleChildren)\n" + 1614 | //k_Tab + k_Tab + k_Tab + k_Tab + "continue;\n" + 1615 | //"\n" + 1616 | //k_Tab + k_Tab + k_Tab + "driver.AddFromName<" + trackBinding.name + ">(trackBinding.gameObject, iterator.propertyPath);\n" + 1617 | //k_Tab + k_Tab + "}\n" + 1618 | StandardBlendPropertiesAssignedToPropertyDriverToString () + 1619 | "#endif\n" + 1620 | k_Tab + k_Tab + "base.GatherProperties (director, driver);\n" + 1621 | k_Tab + "}\n" + 1622 | "}\n"; 1623 | } 1624 | 1625 | string StandardBlendPlayableDrawer () 1626 | { 1627 | return 1628 | "using UnityEditor;\n" + 1629 | "using UnityEngine;\n" + 1630 | "using UnityEngine.Playables;\n" + 1631 | AdditionalNamespacesToString() + 1632 | "\n" + 1633 | "[CustomPropertyDrawer(typeof(" + playableName + k_TimelineClipBehaviourSuffix + "))]\n" + 1634 | "public class " + playableName + k_PropertyDrawerSuffix + " : PropertyDrawer\n" + 1635 | "{\n" + 1636 | k_Tab + "public override float GetPropertyHeight (SerializedProperty property, GUIContent label)\n" + 1637 | k_Tab + "{\n" + 1638 | k_Tab + k_Tab + "int fieldCount = " + standardBlendPlayableProperties.Count + ";\n" + 1639 | k_Tab + k_Tab + "return fieldCount * EditorGUIUtility.singleLineHeight;\n" + 1640 | k_Tab + "}\n" + 1641 | "\n" + 1642 | k_Tab + "public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)\n" + 1643 | k_Tab + "{\n" + 1644 | StandardBlendTrackBindingPropertiesAsSerializedPropsDeclarationToString () + 1645 | "\n" + 1646 | k_Tab + k_Tab + "Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);\n" + 1647 | StandardBlendSerializedPropertyGUIToString () + 1648 | k_Tab + "}\n" + 1649 | "}\n"; 1650 | } 1651 | 1652 | string StandardBlendScriptPlayablePropertiesToString () 1653 | { 1654 | string returnVal = ""; 1655 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1656 | { 1657 | UsableProperty prop = standardBlendPlayableProperties[i]; 1658 | if(prop.defaultValue == "") 1659 | returnVal += k_Tab + "public " + prop.type + " " + prop.name + ";\n"; 1660 | else 1661 | { 1662 | returnVal += k_Tab + "public " + prop.type + " " + prop.name + " = " + prop.defaultValue + ";\n"; 1663 | } 1664 | } 1665 | return returnVal; 1666 | } 1667 | 1668 | string StandardBlendTrackBindingPropertiesDefaultsDeclarationToString () 1669 | { 1670 | string returnVal = ""; 1671 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1672 | { 1673 | UsableProperty prop = standardBlendPlayableProperties[i]; 1674 | returnVal += k_Tab + prop.type + " " + prop.NameAsPrivateDefault + ";\n"; 1675 | } 1676 | return returnVal; 1677 | } 1678 | 1679 | string StandardBlendTrackBindingPropertiesBlendedDeclarationToString () 1680 | { 1681 | string returnVal = ""; 1682 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1683 | { 1684 | UsableProperty prop = standardBlendPlayableProperties[i]; 1685 | 1686 | returnVal += k_Tab + prop.type + " " + prop.NameAsPrivateAssigned + ";\n"; 1687 | } 1688 | return returnVal; 1689 | } 1690 | 1691 | string StandardBlendTrackBindingPropertiesDefaultsAssignmentToString () 1692 | { 1693 | string returnVal = ""; 1694 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1695 | { 1696 | UsableProperty prop = standardBlendPlayableProperties[i]; 1697 | 1698 | switch (prop.type) 1699 | { 1700 | case "float": 1701 | returnVal += k_Tab + k_Tab + "if (!Mathf.Approximately(m_TrackBinding." + prop.name + ", " + prop.NameAsPrivateAssigned + "))\n"; 1702 | returnVal += k_Tab + k_Tab + k_Tab + prop.NameAsPrivateDefault + " = m_TrackBinding." + prop.name + ";\n"; 1703 | break; 1704 | case "double": 1705 | returnVal += k_Tab + k_Tab + "if (!Mathf.Approximately((float)m_TrackBinding." + prop.name + ", (float)" + prop.NameAsPrivateAssigned + "))\n"; 1706 | returnVal += k_Tab + k_Tab + k_Tab + prop.NameAsPrivateDefault + " = m_TrackBinding." + prop.name + ";\n"; 1707 | break; 1708 | default: 1709 | returnVal += k_Tab + k_Tab + "if (m_TrackBinding." + prop.name + " != " + prop.NameAsPrivateAssigned + ")\n"; 1710 | returnVal += k_Tab + k_Tab + k_Tab + prop.NameAsPrivateDefault + " = m_TrackBinding." + prop.name + ";\n"; 1711 | break; 1712 | } 1713 | } 1714 | return returnVal; 1715 | } 1716 | 1717 | string StandardBlendBlendedVariablesCreationToString () 1718 | { 1719 | string returnVal = ""; 1720 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1721 | { 1722 | UsableProperty prop = standardBlendPlayableProperties[i]; 1723 | 1724 | if(prop.usability != UsableProperty.Usability.Blendable) 1725 | continue; 1726 | 1727 | string type = prop.type == "int" ? "float" : prop.type; 1728 | string zeroVal = prop.type == "int" ? "0f" : prop.ZeroValueAsString (); 1729 | returnVal += k_Tab + k_Tab + type + " " + prop.NameAsLocalBlended + " = " + zeroVal + ";\n"; 1730 | } 1731 | return returnVal; 1732 | } 1733 | 1734 | string StandardBlendPlayableCurrentInputsDeclarationToString () 1735 | { 1736 | if (standardBlendPlayableProperties.Any (x => x.usability == UsableProperty.Usability.Assignable)) 1737 | { 1738 | return k_Tab + k_Tab + "int currentInputs = 0;\n"; 1739 | } 1740 | return ""; 1741 | } 1742 | 1743 | string StandardBlendBlendedVariablesWeightedIncrementationToString () 1744 | { 1745 | string returnVal = ""; 1746 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1747 | { 1748 | UsableProperty prop = standardBlendPlayableProperties[i]; 1749 | 1750 | if (prop.usability == UsableProperty.Usability.Blendable) 1751 | returnVal += k_Tab + k_Tab + k_Tab + prop.NameAsLocalBlended + " += input." + prop.name + " * inputWeight;\n"; 1752 | 1753 | } 1754 | return returnVal; 1755 | } 1756 | 1757 | string StandardBlendAssignableVariablesAssignedBasedOnGreatestWeightToString () 1758 | { 1759 | if (standardBlendPlayableProperties.Count == 0) 1760 | return ""; 1761 | 1762 | string returnVal = k_Tab + k_Tab + k_Tab + "if (inputWeight > greatestWeight)\n"; 1763 | returnVal += k_Tab + k_Tab + k_Tab + "{\n"; 1764 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1765 | { 1766 | UsableProperty prop = standardBlendPlayableProperties[i]; 1767 | if (prop.usability == UsableProperty.Usability.Assignable) 1768 | { 1769 | returnVal += k_Tab + k_Tab + k_Tab + k_Tab + prop.NameAsPrivateAssigned + " = input." + prop.name + ";\n"; 1770 | returnVal += k_Tab + k_Tab + k_Tab + k_Tab + "m_TrackBinding." + prop.name + " = " + prop.NameAsPrivateAssigned + ";\n"; 1771 | } 1772 | } 1773 | returnVal += k_Tab + k_Tab + k_Tab + k_Tab + "greatestWeight = inputWeight;\n"; 1774 | returnVal += k_Tab + k_Tab + k_Tab + "}\n"; 1775 | return returnVal; 1776 | } 1777 | 1778 | string StandardBlendPlayableCurrentInputIterationToString () 1779 | { 1780 | if (standardBlendPlayableProperties.Any (x => x.usability == UsableProperty.Usability.Assignable)) 1781 | { 1782 | string returnVal = "\n"; 1783 | returnVal += k_Tab + k_Tab + k_Tab + "if (!Mathf.Approximately (inputWeight, 0f))\n"; 1784 | returnVal += k_Tab + k_Tab + k_Tab + k_Tab + "currentInputs++;\n"; 1785 | return returnVal; 1786 | } 1787 | return ""; 1788 | } 1789 | 1790 | string StandardBlendTrackBindingPropertiesBlendedAssignmentToString () 1791 | { 1792 | string returnVal = ""; 1793 | bool firstNewLine = false; 1794 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1795 | { 1796 | UsableProperty prop = standardBlendPlayableProperties[i]; 1797 | if (prop.usability != UsableProperty.Usability.Blendable) 1798 | continue; 1799 | 1800 | if (!firstNewLine) 1801 | { 1802 | firstNewLine = true; 1803 | returnVal += "\n"; 1804 | } 1805 | 1806 | if (prop.type == "int") 1807 | returnVal += k_Tab + k_Tab + prop.NameAsPrivateAssigned + " = Mathf.RoundToInt (" + prop.NameAsLocalBlended + " + " + prop.NameAsPrivateDefault + " * (1f - totalWeight));\n"; 1808 | else 1809 | returnVal += k_Tab + k_Tab + prop.NameAsPrivateAssigned + " = " + prop.NameAsLocalBlended + " + " + prop.NameAsPrivateDefault + " * (1f - totalWeight);\n"; 1810 | 1811 | returnVal += k_Tab + k_Tab + "m_TrackBinding." + prop.name + " = " + prop.NameAsPrivateAssigned + ";\n"; 1812 | } 1813 | return returnVal; 1814 | } 1815 | 1816 | string StandardBlendTrackBindingPropertiesAssignableAssignmentToString () 1817 | { 1818 | if (standardBlendPlayableProperties.Count == 0) 1819 | return ""; 1820 | 1821 | if (standardBlendPlayableProperties.Any (x => x.usability == UsableProperty.Usability.Assignable)) 1822 | { 1823 | string returnVal = "\n" + k_Tab + k_Tab + "if (currentInputs != 1 && 1f - totalWeight > greatestWeight)\n"; 1824 | returnVal += k_Tab + k_Tab + "{\n"; 1825 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1826 | { 1827 | UsableProperty prop = standardBlendPlayableProperties[i]; 1828 | if (prop.usability != UsableProperty.Usability.Assignable) 1829 | continue; 1830 | 1831 | returnVal += k_Tab + k_Tab + k_Tab + "m_TrackBinding." + prop.name + " = " + prop.NameAsPrivateDefault + ";\n"; 1832 | } 1833 | returnVal += k_Tab + k_Tab + "}\n"; 1834 | return returnVal; 1835 | } 1836 | 1837 | return ""; 1838 | } 1839 | 1840 | string StandardBlendComponentBindingToString () 1841 | { 1842 | return "[TrackBindingType(typeof(" + trackBinding.name + "))]\n"; 1843 | } 1844 | 1845 | string StandardBlendPropertiesAssignedToPropertyDriverToString () 1846 | { 1847 | if (standardBlendPlayableProperties.Count == 0) 1848 | return ""; 1849 | 1850 | string returnVal = k_Tab + k_Tab + "// These field names are procedurally generated estimations based on the associated property names.\n"; 1851 | returnVal += k_Tab + k_Tab + "// If any of the names are incorrect you will get a DrivenPropertyManager error saying it has failed to register the name.\n"; 1852 | returnVal += k_Tab + k_Tab + "// In this case you will need to find the correct backing field name.\n"; 1853 | returnVal += k_Tab + k_Tab + "// The suggested way of finding the field name is to:\n"; 1854 | returnVal += k_Tab + k_Tab + "// 1. Make sure your scene is serialized to text.\n"; 1855 | returnVal += k_Tab + k_Tab + "// 2. Search the text for the track binding component type.\n"; 1856 | returnVal += k_Tab + k_Tab + "// 3. Look through the field names until you see one that looks correct.\n"; 1857 | 1858 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1859 | { 1860 | UsableProperty prop = standardBlendPlayableProperties[i]; 1861 | 1862 | if (prop.usablePropertyType == UsableProperty.UsablePropertyType.Field) 1863 | { 1864 | returnVal += k_Tab + k_Tab + "driver.AddFromName<" + trackBinding.name + ">(trackBinding.gameObject, \"" + prop.name + "\");\n"; 1865 | } 1866 | else 1867 | { 1868 | returnVal += k_Tab + k_Tab + "driver.AddFromName<" + trackBinding.name + ">(trackBinding.gameObject, \"" + prop.NameAsPrivate + "\");\n"; 1869 | } 1870 | } 1871 | 1872 | return returnVal; 1873 | } 1874 | 1875 | string StandardBlendTrackBindingPropertiesAsSerializedPropsDeclarationToString () 1876 | { 1877 | string returnVal = ""; 1878 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1879 | { 1880 | UsableProperty prop = standardBlendPlayableProperties[i]; 1881 | returnVal += k_Tab + k_Tab + "SerializedProperty " + prop.NameAsLocalSerializedProperty + " = property.FindPropertyRelative(\"" + prop.name + "\");\n"; 1882 | } 1883 | return returnVal; 1884 | } 1885 | 1886 | string StandardBlendSerializedPropertyGUIToString () 1887 | { 1888 | string returnVal = ""; 1889 | for (int i = 0; i < standardBlendPlayableProperties.Count; i++) 1890 | { 1891 | if (i != 0) 1892 | { 1893 | returnVal += "\n"; 1894 | returnVal += k_Tab + k_Tab + "singleFieldRect.y += EditorGUIUtility.singleLineHeight;\n"; 1895 | } 1896 | 1897 | returnVal += k_Tab + k_Tab + "EditorGUI.PropertyField(singleFieldRect, " + standardBlendPlayableProperties[i].NameAsLocalSerializedProperty + ");\n"; 1898 | } 1899 | return returnVal; 1900 | } 1901 | } 1902 | -------------------------------------------------------------------------------- /Editor/TimelinePlayableWizard.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01cfeabdfa5f36740b2b9c9658bbb29e 3 | timeCreated: 1490191896 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Editor/TransformTween.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c560c903bbc7d84089ed5183276f9c5 3 | folderAsset: yes 4 | timeCreated: 1489676106 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Editor/TransformTween/TransformTweenDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | [CustomPropertyDrawer(typeof(TransformTweenBehaviour))] 5 | public class TransformTweenDrawer : PropertyDrawer 6 | { 7 | GUIContent m_TweenPositionContent = new GUIContent("Tween Position", "This should be true if the transformToMove to change position. This causes recalulations each frame which are more CPU intensive."); 8 | GUIContent m_TweenRotationContent = new GUIContent("Tween Rotation", "This should be true if the transformToMove to change rotation."); 9 | GUIContent m_TweenTypeContent = new GUIContent("Tween Type", "Linear - the transform moves the same amount each frame (assuming static start and end locations).\n" 10 | + "Deceleration - the transform moves slower the closer to the end location it is.\n" 11 | + "Harmonic - the transform moves faster in the middle of its tween.\n" 12 | + "Custom - uses the customStartingSpeed and customEndingSpeed to create a curve for the desired tween."); 13 | GUIContent m_CustomCurveContent = new GUIContent("Custom Curve", "This should be a normalised curve (between 0,0 and 1,1) that represents how the tweening object accelerates at different points along the clip."); 14 | 15 | public override float GetPropertyHeight (SerializedProperty property, GUIContent label) 16 | { 17 | int fieldCount = property.FindPropertyRelative ("tweenType").enumValueIndex == (int)TransformTweenBehaviour.TweenType.Custom ? 5 : 3; 18 | return fieldCount * (EditorGUIUtility.singleLineHeight); 19 | } 20 | 21 | public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 22 | { 23 | SerializedProperty tweenPositionProp = property.FindPropertyRelative ("tweenPosition"); 24 | SerializedProperty tweenRotationProp = property.FindPropertyRelative("tweenRotation"); 25 | SerializedProperty tweenTypeProp = property.FindPropertyRelative ("tweenType"); 26 | 27 | Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); 28 | EditorGUI.PropertyField (singleFieldRect, tweenPositionProp, m_TweenPositionContent); 29 | 30 | singleFieldRect.y += EditorGUIUtility.singleLineHeight; 31 | EditorGUI.PropertyField (singleFieldRect, tweenRotationProp, m_TweenRotationContent); 32 | 33 | singleFieldRect.y += EditorGUIUtility.singleLineHeight; 34 | EditorGUI.PropertyField(singleFieldRect, tweenTypeProp, m_TweenTypeContent); 35 | 36 | if (tweenTypeProp.enumValueIndex == (int)TransformTweenBehaviour.TweenType.Custom) 37 | { 38 | SerializedProperty customCurveProp = property.FindPropertyRelative ("customCurve"); 39 | 40 | singleFieldRect.y += EditorGUIUtility.singleLineHeight; 41 | EditorGUI.PropertyField (singleFieldRect, customCurveProp, m_CustomCurveContent); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Editor/TransformTween/TransformTweenDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4c9e800b8d9b3344850b4b658de699d 3 | timeCreated: 1491229652 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Editor/com.uap.defaultplayables.editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.uap.defaultplayables.editor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:bfd171d7973349b40b5fcf659e635d18", 6 | "GUID:f06555f75b070af458a003d92f9efb00" 7 | ], 8 | "includePlatforms": [ 9 | "Editor" 10 | ], 11 | "excludePlatforms": [], 12 | "allowUnsafeCode": false, 13 | "overrideReferences": false, 14 | "precompiledReferences": [], 15 | "autoReferenced": true, 16 | "defineConstraints": [], 17 | "versionDefines": [], 18 | "noEngineReferences": false 19 | } -------------------------------------------------------------------------------- /Editor/com.uap.defaultplayables.editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27204914297331442b594a668c64c12e 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DefaultPlayables 2 | 3 | (From https://assetstore.unity.com/packages/essentials/default-playables-95266 because for some reason Unity haven't uploaded this to a git repo) 4 | 5 | This package includes both the Timeline Playables Wizard and a number of example Playables for you to use with Timeline. 6 | 7 | The Timeline Playables Wizard is a tool to help you write all the boiler plate code for your Playables for use with Timeline. In some cases it will write all of the code for you! 8 | 9 | The example Playables include: 10 | 11 | * LightControl 12 | * NavMeshControl 13 | * ScreenFader 14 | * TextSwitcher 15 | * TimeDilation 16 | * TransformTween 17 | * Video 18 | 19 | Documentation on how to use everything in the package is included as a pdf. 20 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec0fe3e833a9aae47b6d92379f6c85f1 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb6b834e8b70ced42b858f979402bfa1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/LightControl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f5e3cf7f402b7b40894a67f55fad9ce 3 | folderAsset: yes 4 | timeCreated: 1496914998 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Runtime/LightControl/LightControlBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class LightControlBehaviour : PlayableBehaviour 8 | { 9 | public Color color = Color.white; 10 | public float intensity = 1f; 11 | public float bounceIntensity = 1f; 12 | public float range = 10f; 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/LightControl/LightControlBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e7c747bf1731824682c539494feba37 3 | timeCreated: 1496915002 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/LightControl/LightControlClip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class LightControlClip : PlayableAsset, ITimelineClipAsset 8 | { 9 | public LightControlBehaviour template = new LightControlBehaviour (); 10 | 11 | public ClipCaps clipCaps 12 | { 13 | get { return ClipCaps.Blending; } 14 | } 15 | 16 | public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) 17 | { 18 | var playable = ScriptPlayable.Create (graph, template); 19 | return playable; } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/LightControl/LightControlClip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23b46759ef7b0fd4bb74d73bf4d2839b 3 | timeCreated: 1496915002 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/LightControl/LightControlMixerBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | public class LightControlMixerBehaviour : PlayableBehaviour 7 | { 8 | Color m_DefaultColor; 9 | float m_DefaultIntensity; 10 | float m_DefaultBounceIntensity; 11 | float m_DefaultRange; 12 | 13 | Light m_TrackBinding; 14 | bool m_FirstFrameHappened; 15 | 16 | public override void ProcessFrame(Playable playable, FrameData info, object playerData) 17 | { 18 | m_TrackBinding = playerData as Light; 19 | 20 | if (m_TrackBinding == null) 21 | return; 22 | 23 | if (!m_FirstFrameHappened) 24 | { 25 | m_DefaultColor = m_TrackBinding.color; 26 | m_DefaultIntensity = m_TrackBinding.intensity; 27 | m_DefaultBounceIntensity = m_TrackBinding.bounceIntensity; 28 | m_DefaultRange = m_TrackBinding.range; 29 | m_FirstFrameHappened = true; 30 | } 31 | 32 | int inputCount = playable.GetInputCount (); 33 | 34 | Color blendedColor = Color.clear; 35 | float blendedIntensity = 0f; 36 | float blendedBounceIntensity = 0f; 37 | float blendedRange = 0f; 38 | float totalWeight = 0f; 39 | float greatestWeight = 0f; 40 | int currentInputs = 0; 41 | 42 | for (int i = 0; i < inputCount; i++) 43 | { 44 | float inputWeight = playable.GetInputWeight(i); 45 | ScriptPlayable inputPlayable = (ScriptPlayable)playable.GetInput(i); 46 | LightControlBehaviour input = inputPlayable.GetBehaviour (); 47 | 48 | blendedColor += input.color * inputWeight; 49 | blendedIntensity += input.intensity * inputWeight; 50 | blendedBounceIntensity += input.bounceIntensity * inputWeight; 51 | blendedRange += input.range * inputWeight; 52 | totalWeight += inputWeight; 53 | 54 | if (inputWeight > greatestWeight) 55 | { 56 | greatestWeight = inputWeight; 57 | } 58 | 59 | if (!Mathf.Approximately (inputWeight, 0f)) 60 | currentInputs++; 61 | } 62 | 63 | m_TrackBinding.color = blendedColor + m_DefaultColor * (1f - totalWeight); 64 | m_TrackBinding.intensity = blendedIntensity + m_DefaultIntensity * (1f - totalWeight); 65 | m_TrackBinding.bounceIntensity = blendedBounceIntensity + m_DefaultBounceIntensity * (1f - totalWeight); 66 | m_TrackBinding.range = blendedRange + m_DefaultRange * (1f - totalWeight); 67 | } 68 | 69 | public override void OnPlayableDestroy (Playable playable) 70 | { 71 | m_FirstFrameHappened = false; 72 | 73 | if(m_TrackBinding == null) 74 | return; 75 | 76 | m_TrackBinding.color = m_DefaultColor; 77 | m_TrackBinding.intensity = m_DefaultIntensity; 78 | m_TrackBinding.bounceIntensity = m_DefaultBounceIntensity; 79 | m_TrackBinding.range = m_DefaultRange; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Runtime/LightControl/LightControlMixerBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6ddd7db188548f49bf8d55102e62b63 3 | timeCreated: 1496915002 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/LightControl/LightControlTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | using UnityEngine.Timeline; 4 | using System.Collections.Generic; 5 | 6 | [TrackColor(0.9454092f, 0.9779412f, 0.3883002f)] 7 | [TrackClipType(typeof(LightControlClip))] 8 | [TrackBindingType(typeof(Light))] 9 | public class LightControlTrack : TrackAsset 10 | { 11 | public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) 12 | { 13 | return ScriptPlayable.Create (graph, inputCount); 14 | } 15 | 16 | public override void GatherProperties(PlayableDirector director, IPropertyCollector driver) 17 | { 18 | #if UNITY_EDITOR 19 | Light trackBinding = director.GetGenericBinding(this) as Light; 20 | if (trackBinding == null) 21 | return; 22 | driver.AddFromName(trackBinding.gameObject, "m_Color"); 23 | driver.AddFromName(trackBinding.gameObject, "m_Intensity"); 24 | driver.AddFromName(trackBinding.gameObject, "m_Range"); 25 | driver.AddFromName(trackBinding.gameObject, "m_BounceIntensity"); 26 | #endif 27 | base.GatherProperties(director, driver); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Runtime/LightControl/LightControlTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e97b7684a1a63ed42afa5e89e962140f 3 | timeCreated: 1496915002 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93b4d74e1158a4d48914db94fc4e87c9 3 | folderAsset: yes 4 | timeCreated: 1492603101 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl/NavMeshAgentControlBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class NavMeshAgentControlBehaviour : PlayableBehaviour 8 | { 9 | public Transform destination; 10 | public bool destinationSet; 11 | 12 | public override void OnPlayableCreate (Playable playable) 13 | { 14 | destinationSet = false; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl/NavMeshAgentControlBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05bbdc6a3b254694e8d1e2d9d55cd256 3 | timeCreated: 1492603101 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl/NavMeshAgentControlClip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class NavMeshAgentControlClip : PlayableAsset, ITimelineClipAsset 8 | { 9 | public ExposedReference destination; 10 | [HideInInspector] 11 | public NavMeshAgentControlBehaviour template = new NavMeshAgentControlBehaviour (); 12 | 13 | public ClipCaps clipCaps 14 | { 15 | get { return ClipCaps.None; } 16 | } 17 | 18 | public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) 19 | { 20 | var playable = ScriptPlayable.Create (graph, template); 21 | NavMeshAgentControlBehaviour clone = playable.GetBehaviour (); 22 | clone.destination = destination.Resolve (graph.GetResolver ()); 23 | return playable; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl/NavMeshAgentControlClip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cfedc374dca69334db907af09ba5c404 3 | timeCreated: 1492603101 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl/NavMeshAgentControlMixerBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | using UnityEngine.AI; 6 | 7 | public class NavMeshAgentControlMixerBehaviour : PlayableBehaviour 8 | { 9 | public override void ProcessFrame(Playable playable, FrameData info, object playerData) 10 | { 11 | NavMeshAgent trackBinding = playerData as NavMeshAgent; 12 | 13 | if (!trackBinding) 14 | return; 15 | 16 | int inputCount = playable.GetInputCount(); 17 | 18 | for (int i = 0; i < inputCount; i++) 19 | { 20 | float inputWeight = playable.GetInputWeight(i); 21 | ScriptPlayable inputPlayable = (ScriptPlayable)playable.GetInput(i); 22 | NavMeshAgentControlBehaviour input = inputPlayable.GetBehaviour(); 23 | 24 | if (inputWeight > 0.5f && !input.destinationSet && input.destination) 25 | { 26 | if (!trackBinding.isOnNavMesh) 27 | continue; 28 | 29 | trackBinding.SetDestination (input.destination.position); 30 | input.destinationSet = true; 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl/NavMeshAgentControlMixerBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3805dde487857b41b2fff7d26f06f1e 3 | timeCreated: 1492603101 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl/NavMeshAgentControlTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | using UnityEngine.Timeline; 4 | using UnityEngine.AI; 5 | 6 | [TrackColor(0.855f, 0.8623f, 0.87f)] 7 | [TrackClipType(typeof(NavMeshAgentControlClip))] 8 | [TrackBindingType(typeof(NavMeshAgent))] 9 | public class NavMeshAgentControlTrack : TrackAsset 10 | { 11 | public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) 12 | { 13 | return ScriptPlayable.Create (graph, inputCount); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Runtime/NavMeshAgentControl/NavMeshAgentControlTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d201ca921ed322e418c25df03740a308 3 | timeCreated: 1492603101 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/ScreenFader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1482b2b9e18dc0a43baf3c92d0cd7156 3 | folderAsset: yes 4 | timeCreated: 1496916559 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Runtime/ScreenFader/ScreenFaderBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | using UnityEngine.UI; 6 | 7 | [Serializable] 8 | public class ScreenFaderBehaviour : PlayableBehaviour 9 | { 10 | public Color color = Color.black; 11 | } 12 | -------------------------------------------------------------------------------- /Runtime/ScreenFader/ScreenFaderBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cf88cabc4dadeb4fafeefdbc61869ca 3 | timeCreated: 1496916563 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/ScreenFader/ScreenFaderClip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class ScreenFaderClip : PlayableAsset, ITimelineClipAsset 8 | { 9 | public ScreenFaderBehaviour template = new ScreenFaderBehaviour (); 10 | 11 | public ClipCaps clipCaps 12 | { 13 | get { return ClipCaps.Blending; } 14 | } 15 | 16 | public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) 17 | { 18 | var playable = ScriptPlayable.Create (graph, template); 19 | return playable; } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/ScreenFader/ScreenFaderClip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0445258a5c40b364ab21547784905327 3 | timeCreated: 1496916563 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/ScreenFader/ScreenFaderMixerBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | using UnityEngine.UI; 6 | 7 | public class ScreenFaderMixerBehaviour : PlayableBehaviour 8 | { 9 | Color m_DefaultColor; 10 | 11 | Image m_TrackBinding; 12 | bool m_FirstFrameHappened; 13 | 14 | public override void ProcessFrame(Playable playable, FrameData info, object playerData) 15 | { 16 | m_TrackBinding = playerData as Image; 17 | 18 | if (m_TrackBinding == null) 19 | return; 20 | 21 | if (!m_FirstFrameHappened) 22 | { 23 | m_DefaultColor = m_TrackBinding.color; 24 | m_FirstFrameHappened = true; 25 | } 26 | 27 | int inputCount = playable.GetInputCount (); 28 | 29 | Color blendedColor = Color.clear; 30 | float totalWeight = 0f; 31 | float greatestWeight = 0f; 32 | int currentInputs = 0; 33 | 34 | for (int i = 0; i < inputCount; i++) 35 | { 36 | float inputWeight = playable.GetInputWeight(i); 37 | ScriptPlayable inputPlayable = (ScriptPlayable)playable.GetInput(i); 38 | ScreenFaderBehaviour input = inputPlayable.GetBehaviour (); 39 | 40 | blendedColor += input.color * inputWeight; 41 | totalWeight += inputWeight; 42 | 43 | if (inputWeight > greatestWeight) 44 | { 45 | greatestWeight = inputWeight; 46 | } 47 | 48 | if (!Mathf.Approximately (inputWeight, 0f)) 49 | currentInputs++; 50 | } 51 | 52 | m_TrackBinding.color = blendedColor + m_DefaultColor * (1f - totalWeight); 53 | } 54 | 55 | public override void OnPlayableDestroy (Playable playable) 56 | { 57 | m_FirstFrameHappened = false; 58 | 59 | if (m_TrackBinding == null) 60 | return; 61 | 62 | m_TrackBinding.color = m_DefaultColor; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Runtime/ScreenFader/ScreenFaderMixerBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88173aff48b4ccb429d83dca32d03a86 3 | timeCreated: 1496916563 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/ScreenFader/ScreenFaderTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | using UnityEngine.Timeline; 4 | using System.Collections.Generic; 5 | using UnityEngine.UI; 6 | 7 | [TrackColor(0.875f, 0.5944853f, 0.1737132f)] 8 | [TrackClipType(typeof(ScreenFaderClip))] 9 | [TrackBindingType(typeof(Image))] 10 | public class ScreenFaderTrack : TrackAsset 11 | { 12 | public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) 13 | { 14 | return ScriptPlayable.Create (graph, inputCount); 15 | } 16 | 17 | public override void GatherProperties (PlayableDirector director, IPropertyCollector driver) 18 | { 19 | #if UNITY_EDITOR 20 | Image trackBinding = director.GetGenericBinding(this) as Image; 21 | if (trackBinding == null) 22 | return; 23 | 24 | var serializedObject = new UnityEditor.SerializedObject (trackBinding); 25 | var iterator = serializedObject.GetIterator(); 26 | while (iterator.NextVisible(true)) 27 | { 28 | if (iterator.hasVisibleChildren) 29 | continue; 30 | 31 | driver.AddFromName(trackBinding.gameObject, iterator.propertyPath); 32 | } 33 | #endif 34 | base.GatherProperties (director, driver); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Runtime/ScreenFader/ScreenFaderTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a8190b9dc143d64ab3322e49af85f7b 3 | timeCreated: 1496916563 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d691e3fbd7f57c4d81cf41595ca9cc7 3 | folderAsset: yes 4 | timeCreated: 1496915575 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher/TextSwitcherBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | using UnityEngine.UI; 6 | 7 | [Serializable] 8 | public class TextSwitcherBehaviour : PlayableBehaviour 9 | { 10 | public Color color = Color.white; 11 | public int fontSize = 14; 12 | public string text; 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher/TextSwitcherBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6480896635305a7418e42ec32d3c64d3 3 | timeCreated: 1496915579 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher/TextSwitcherClip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class TextSwitcherClip : PlayableAsset, ITimelineClipAsset 8 | { 9 | public TextSwitcherBehaviour template = new TextSwitcherBehaviour (); 10 | 11 | public ClipCaps clipCaps 12 | { 13 | get { return ClipCaps.Blending; } 14 | } 15 | 16 | public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) 17 | { 18 | var playable = ScriptPlayable.Create (graph, template); 19 | return playable; } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher/TextSwitcherClip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4d683f551d33a84db12bb6fa65573f9 3 | timeCreated: 1496915579 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher/TextSwitcherMixerBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | using UnityEngine.UI; 6 | 7 | public class TextSwitcherMixerBehaviour : PlayableBehaviour 8 | { 9 | Color m_DefaultColor; 10 | int m_DefaultFontSize; 11 | string m_DefaultText; 12 | 13 | Text m_TrackBinding; 14 | bool m_FirstFrameHappened; 15 | 16 | public override void ProcessFrame(Playable playable, FrameData info, object playerData) 17 | { 18 | m_TrackBinding = playerData as Text; 19 | 20 | if (m_TrackBinding == null) 21 | return; 22 | 23 | if (!m_FirstFrameHappened) 24 | { 25 | m_DefaultColor = m_TrackBinding.color; 26 | m_DefaultFontSize = m_TrackBinding.fontSize; 27 | m_DefaultText = m_TrackBinding.text; 28 | m_FirstFrameHappened = true; 29 | } 30 | 31 | int inputCount = playable.GetInputCount (); 32 | 33 | Color blendedColor = Color.clear; 34 | float blendedFontSize = 0f; 35 | float totalWeight = 0f; 36 | float greatestWeight = 0f; 37 | int currentInputs = 0; 38 | 39 | for (int i = 0; i < inputCount; i++) 40 | { 41 | float inputWeight = playable.GetInputWeight(i); 42 | ScriptPlayable inputPlayable = (ScriptPlayable)playable.GetInput(i); 43 | TextSwitcherBehaviour input = inputPlayable.GetBehaviour (); 44 | 45 | blendedColor += input.color * inputWeight; 46 | blendedFontSize += input.fontSize * inputWeight; 47 | totalWeight += inputWeight; 48 | 49 | if (inputWeight > greatestWeight) 50 | { 51 | m_TrackBinding.text = input.text; 52 | greatestWeight = inputWeight; 53 | } 54 | 55 | if (!Mathf.Approximately (inputWeight, 0f)) 56 | currentInputs++; 57 | } 58 | 59 | m_TrackBinding.color = blendedColor + m_DefaultColor * (1f - totalWeight); 60 | m_TrackBinding.fontSize = Mathf.RoundToInt (blendedFontSize + m_DefaultFontSize * (1f - totalWeight)); 61 | if (currentInputs != 1 && 1f - totalWeight > greatestWeight) 62 | { 63 | m_TrackBinding.text = m_DefaultText; 64 | } 65 | } 66 | 67 | public override void OnPlayableDestroy (Playable playable) 68 | { 69 | m_FirstFrameHappened = false; 70 | 71 | if (m_TrackBinding == null) 72 | return; 73 | 74 | m_TrackBinding.color = m_DefaultColor; 75 | m_TrackBinding.fontSize = m_DefaultFontSize; 76 | m_TrackBinding.text = m_DefaultText; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher/TextSwitcherMixerBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a4266a3acde3c24e995780329819997 3 | timeCreated: 1496915579 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher/TextSwitcherTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | using UnityEngine.Timeline; 4 | using System.Collections.Generic; 5 | using UnityEngine.UI; 6 | 7 | [TrackColor(0.1394896f, 0.4411765f, 0.3413077f)] 8 | [TrackClipType(typeof(TextSwitcherClip))] 9 | [TrackBindingType(typeof(Text))] 10 | public class TextSwitcherTrack : TrackAsset 11 | { 12 | public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) 13 | { 14 | return ScriptPlayable.Create (graph, inputCount); 15 | } 16 | 17 | public override void GatherProperties (PlayableDirector director, IPropertyCollector driver) 18 | { 19 | #if UNITY_EDITOR 20 | Text trackBinding = director.GetGenericBinding(this) as Text; 21 | if (trackBinding == null) 22 | return; 23 | 24 | var serializedObject = new UnityEditor.SerializedObject (trackBinding); 25 | var iterator = serializedObject.GetIterator(); 26 | while (iterator.NextVisible(true)) 27 | { 28 | if (iterator.hasVisibleChildren) 29 | continue; 30 | 31 | driver.AddFromName(trackBinding.gameObject, iterator.propertyPath); 32 | } 33 | #endif 34 | base.GatherProperties (director, driver); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Runtime/TextSwitcher/TextSwitcherTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73211584ea373f3409e0a7a83d711aef 3 | timeCreated: 1496915579 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TimeDilation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ee2af8470937c74ebb226b59fab0f6c 3 | folderAsset: yes 4 | timeCreated: 1491318587 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Runtime/TimeDilation/TimeDilationBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class TimeDilationBehaviour : PlayableBehaviour 8 | { 9 | public float timeScale = 1f; 10 | } 11 | -------------------------------------------------------------------------------- /Runtime/TimeDilation/TimeDilationBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0b944926d9e8514d892737116110502 3 | timeCreated: 1491318587 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TimeDilation/TimeDilationClip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class TimeDilationClip : PlayableAsset, ITimelineClipAsset 8 | { 9 | public TimeDilationBehaviour template = new TimeDilationBehaviour (); 10 | 11 | public ClipCaps clipCaps 12 | { 13 | get { return ClipCaps.Extrapolation | ClipCaps.Blending; } 14 | } 15 | 16 | public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) 17 | { 18 | return ScriptPlayable.Create (graph, template); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/TimeDilation/TimeDilationClip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eed9a3f59ff436340b05ff8248f0d998 3 | timeCreated: 1491318587 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TimeDilation/TimeDilationMixerBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | public class TimeDilationMixerBehaviour : PlayableBehaviour 7 | { 8 | readonly float defaultTimeScale = 1f; 9 | 10 | public override void ProcessFrame(Playable playable, FrameData info, object playerData) 11 | { 12 | int inputCount = playable.GetInputCount (); 13 | 14 | float mixedTimeScale = 0f; 15 | float totalWeight = 0f; 16 | int currentInputCount = 0; 17 | 18 | for (int i = 0; i < inputCount; i++) 19 | { 20 | float inputWeight = playable.GetInputWeight(i); 21 | 22 | if (inputWeight > 0f) 23 | currentInputCount++; 24 | 25 | totalWeight += inputWeight; 26 | 27 | ScriptPlayable playableInput = (ScriptPlayable)playable.GetInput (i); 28 | TimeDilationBehaviour input = playableInput.GetBehaviour (); 29 | 30 | mixedTimeScale += inputWeight * input.timeScale; 31 | } 32 | 33 | Time.timeScale = mixedTimeScale + defaultTimeScale * (1f - totalWeight); 34 | 35 | if (currentInputCount == 0) 36 | Time.timeScale = defaultTimeScale; 37 | } 38 | 39 | public override void OnBehaviourPause (Playable playable, FrameData info) 40 | { 41 | Time.timeScale = defaultTimeScale; 42 | } 43 | 44 | public override void OnGraphStop (Playable playable) 45 | { 46 | Time.timeScale = defaultTimeScale; 47 | } 48 | 49 | public override void OnPlayableDestroy (Playable playable) 50 | { 51 | Time.timeScale = defaultTimeScale; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Runtime/TimeDilation/TimeDilationMixerBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64af3ceaf545d3341b852718827f2b64 3 | timeCreated: 1491318587 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TimeDilation/TimeDilationTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | using UnityEngine.Timeline; 4 | 5 | [TrackColor(0.855f, 0.8623f, 0.87f)] 6 | [TrackClipType(typeof(TimeDilationClip))] 7 | public class TimeDilationTrack : TrackAsset 8 | { 9 | public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) 10 | { 11 | return ScriptPlayable.Create (graph, inputCount); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/TimeDilation/TimeDilationTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0282fd402247fd34eb165b280236e58a 3 | timeCreated: 1491318587 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TransformTween.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 770abf86f6667884f903a5e1966bc2f9 3 | folderAsset: yes 4 | timeCreated: 1489416105 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Runtime/TransformTween/TransformTweenBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using JetBrains.Annotations; 3 | using UnityEngine; 4 | using UnityEngine.Playables; 5 | using UnityEngine.Timeline; 6 | 7 | [Serializable] 8 | public class TransformTweenBehaviour : PlayableBehaviour 9 | { 10 | public enum TweenType 11 | { 12 | Linear, 13 | Deceleration, 14 | Harmonic, 15 | Custom, 16 | } 17 | 18 | public Transform startLocation; 19 | public Transform endLocation; 20 | public bool tweenPosition = true; 21 | public bool tweenRotation = true; 22 | public TweenType tweenType; 23 | public AnimationCurve customCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); 24 | 25 | public Vector3 startingPosition; 26 | public Quaternion startingRotation = Quaternion.identity; 27 | 28 | AnimationCurve m_LinearCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); 29 | AnimationCurve m_DecelerationCurve = new AnimationCurve 30 | ( 31 | new Keyframe(0f, 0f, -k_RightAngleInRads, k_RightAngleInRads), 32 | new Keyframe(1f, 1f, 0f, 0f) 33 | ); 34 | AnimationCurve m_HarmonicCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); 35 | 36 | const float k_RightAngleInRads = Mathf.PI * 0.5f; 37 | 38 | public override void PrepareFrame (Playable playable, FrameData info) 39 | { 40 | if (startLocation) 41 | { 42 | startingPosition = startLocation.position; 43 | startingRotation = startLocation.rotation; 44 | } 45 | } 46 | 47 | public float EvaluateCurrentCurve (float time) 48 | { 49 | if (tweenType == TweenType.Custom && !IsCustomCurveNormalised ()) 50 | { 51 | Debug.LogError("Custom Curve is not normalised. Curve must start at 0,0 and end at 1,1."); 52 | return 0f; 53 | } 54 | 55 | switch (tweenType) 56 | { 57 | case TweenType.Linear: 58 | return m_LinearCurve.Evaluate (time); 59 | case TweenType.Deceleration: 60 | return m_DecelerationCurve.Evaluate (time); 61 | case TweenType.Harmonic: 62 | return m_HarmonicCurve.Evaluate (time); 63 | default: 64 | return customCurve.Evaluate (time); 65 | } 66 | } 67 | 68 | bool IsCustomCurveNormalised () 69 | { 70 | if (!Mathf.Approximately (customCurve[0].time, 0f)) 71 | return false; 72 | 73 | if (!Mathf.Approximately (customCurve[0].value, 0f)) 74 | return false; 75 | 76 | if (!Mathf.Approximately (customCurve[customCurve.length - 1].time, 1f)) 77 | return false; 78 | 79 | return Mathf.Approximately (customCurve[customCurve.length - 1].value, 1f); 80 | } 81 | } -------------------------------------------------------------------------------- /Runtime/TransformTween/TransformTweenBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0594bfd3cbfda4d4bab34de00fb2faed 3 | timeCreated: 1493024223 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TransformTween/TransformTweenClip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Timeline; 5 | 6 | [Serializable] 7 | public class TransformTweenClip : PlayableAsset, ITimelineClipAsset 8 | { 9 | public TransformTweenBehaviour template = new TransformTweenBehaviour (); 10 | public ExposedReference startLocation; 11 | public ExposedReference endLocation; 12 | 13 | public ClipCaps clipCaps 14 | { 15 | get { return ClipCaps.Blending; } 16 | } 17 | 18 | public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) 19 | { 20 | var playable = ScriptPlayable.Create (graph, template); 21 | TransformTweenBehaviour clone = playable.GetBehaviour (); 22 | clone.startLocation = startLocation.Resolve (graph.GetResolver ()); 23 | clone.endLocation = endLocation.Resolve (graph.GetResolver ()); 24 | return playable; 25 | } 26 | } -------------------------------------------------------------------------------- /Runtime/TransformTween/TransformTweenClip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f28fb04ff66f85e40af453230799042c 3 | timeCreated: 1489416659 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TransformTween/TransformTweenMixerBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Playables; 4 | 5 | public class TransformTweenMixerBehaviour : PlayableBehaviour 6 | { 7 | bool m_FirstFrameHappened; 8 | 9 | public override void ProcessFrame(Playable playable, FrameData info, object playerData) 10 | { 11 | Transform trackBinding = playerData as Transform; 12 | 13 | if(trackBinding == null) 14 | return; 15 | 16 | Vector3 defaultPosition = trackBinding.position; 17 | Quaternion defaultRotation = trackBinding.rotation; 18 | 19 | int inputCount = playable.GetInputCount (); 20 | 21 | float positionTotalWeight = 0f; 22 | float rotationTotalWeight = 0f; 23 | 24 | Vector3 blendedPosition = Vector3.zero; 25 | Quaternion blendedRotation = new Quaternion(0f, 0f, 0f, 0f); 26 | 27 | for (int i = 0; i < inputCount; i++) 28 | { 29 | ScriptPlayable playableInput = (ScriptPlayable)playable.GetInput (i); 30 | TransformTweenBehaviour input = playableInput.GetBehaviour (); 31 | 32 | if(input.endLocation == null) 33 | continue; 34 | 35 | float inputWeight = playable.GetInputWeight(i); 36 | 37 | if (!m_FirstFrameHappened && !input.startLocation) 38 | { 39 | input.startingPosition = defaultPosition; 40 | input.startingRotation = defaultRotation; 41 | } 42 | 43 | float normalisedTime = (float)(playableInput.GetTime() / playableInput.GetDuration ()); 44 | float tweenProgress = input.EvaluateCurrentCurve(normalisedTime); 45 | 46 | if (input.tweenPosition) 47 | { 48 | positionTotalWeight += inputWeight; 49 | 50 | blendedPosition += Vector3.Lerp(input.startingPosition, input.endLocation.position, tweenProgress) * inputWeight; 51 | } 52 | 53 | if (input.tweenRotation) 54 | { 55 | rotationTotalWeight += inputWeight; 56 | 57 | Quaternion desiredRotation = Quaternion.Lerp(input.startingRotation, input.endLocation.rotation, tweenProgress); 58 | desiredRotation = NormalizeQuaternion(desiredRotation); 59 | 60 | if (Quaternion.Dot (blendedRotation, desiredRotation) < 0f) 61 | { 62 | desiredRotation = ScaleQuaternion (desiredRotation, -1f); 63 | } 64 | 65 | desiredRotation = ScaleQuaternion(desiredRotation, inputWeight); 66 | 67 | blendedRotation = AddQuaternions (blendedRotation, desiredRotation); 68 | } 69 | } 70 | 71 | blendedPosition += defaultPosition * (1f - positionTotalWeight); 72 | Quaternion weightedDefaultRotation = ScaleQuaternion (defaultRotation, 1f - rotationTotalWeight); 73 | blendedRotation = AddQuaternions (blendedRotation, weightedDefaultRotation); 74 | 75 | trackBinding.position = blendedPosition; 76 | trackBinding.rotation = blendedRotation; 77 | 78 | m_FirstFrameHappened = true; 79 | } 80 | 81 | public override void OnPlayableDestroy (Playable playable) 82 | { 83 | m_FirstFrameHappened = false; 84 | } 85 | 86 | static Quaternion AddQuaternions (Quaternion first, Quaternion second) 87 | { 88 | first.w += second.w; 89 | first.x += second.x; 90 | first.y += second.y; 91 | first.z += second.z; 92 | return first; 93 | } 94 | 95 | static Quaternion ScaleQuaternion (Quaternion rotation, float multiplier) 96 | { 97 | rotation.w *= multiplier; 98 | rotation.x *= multiplier; 99 | rotation.y *= multiplier; 100 | rotation.z *= multiplier; 101 | return rotation; 102 | } 103 | 104 | static float QuaternionMagnitude (Quaternion rotation) 105 | { 106 | return Mathf.Sqrt ((Quaternion.Dot (rotation, rotation))); 107 | } 108 | 109 | static Quaternion NormalizeQuaternion (Quaternion rotation) 110 | { 111 | float magnitude = QuaternionMagnitude (rotation); 112 | 113 | if (magnitude > 0f) 114 | return ScaleQuaternion (rotation, 1f / magnitude); 115 | 116 | Debug.LogWarning ("Cannot normalize a quaternion with zero magnitude."); 117 | return Quaternion.identity; 118 | } 119 | } -------------------------------------------------------------------------------- /Runtime/TransformTween/TransformTweenMixerBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e904ec43bfb67e843b3b830e3d2adc1d 3 | timeCreated: 1493024236 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/TransformTween/TransformTweenTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | using UnityEngine.Timeline; 4 | 5 | [TrackColor(0.855f,0.8623f,0.870f)] 6 | [TrackClipType(typeof(TransformTweenClip))] 7 | [TrackBindingType(typeof(Transform))] 8 | public class TransformTweenTrack : TrackAsset 9 | { 10 | public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) 11 | { 12 | return ScriptPlayable.Create (graph, inputCount); 13 | } 14 | 15 | public override void GatherProperties(PlayableDirector director, IPropertyCollector driver) 16 | { 17 | #if UNITY_EDITOR 18 | var comp = director.GetGenericBinding(this) as Transform; 19 | if (comp == null) 20 | return; 21 | var so = new UnityEditor.SerializedObject(comp); 22 | var iter = so.GetIterator(); 23 | while (iter.NextVisible(true)) 24 | { 25 | if (iter.hasVisibleChildren) 26 | continue; 27 | driver.AddFromName(comp.gameObject, iter.propertyPath); 28 | } 29 | #endif 30 | base.GatherProperties(director, driver); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Runtime/TransformTween/TransformTweenTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2e6ab84ba07902498da4807885565cb 3 | timeCreated: 1489416673 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/Video.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3beda1e3675ee5a438601ebe0052d01d 3 | folderAsset: yes 4 | timeCreated: 1497258609 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Runtime/Video/VideoPlayableBehaviour.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | using UnityEngine.Video; 4 | 5 | namespace UnityEngine.Timeline 6 | { 7 | public class VideoPlayableBehaviour : PlayableBehaviour 8 | { 9 | public VideoPlayer videoPlayer; 10 | public VideoClip videoClip; 11 | public bool mute = false; 12 | public bool loop = true; 13 | public double preloadTime = 0.3; 14 | public double clipInTime = 0.0; 15 | 16 | private bool playedOnce = false; 17 | private bool preparing = false; 18 | 19 | public void PrepareVideo() 20 | { 21 | if (videoPlayer == null || videoClip == null) 22 | return; 23 | 24 | videoPlayer.targetCameraAlpha = 0.0f; 25 | 26 | if (videoPlayer.clip != videoClip) 27 | StopVideo(); 28 | 29 | if (videoPlayer.isPrepared || preparing) 30 | return; 31 | 32 | videoPlayer.source = VideoSource.VideoClip; 33 | videoPlayer.clip = videoClip; 34 | videoPlayer.playOnAwake = false; 35 | videoPlayer.waitForFirstFrame = true; 36 | videoPlayer.isLooping = loop; 37 | 38 | for (ushort i = 0; i < videoClip.audioTrackCount; ++i) 39 | { 40 | if (videoPlayer.audioOutputMode == VideoAudioOutputMode.Direct) 41 | videoPlayer.SetDirectAudioMute(i, mute || !Application.isPlaying); 42 | else if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) 43 | { 44 | AudioSource audioSource = videoPlayer.GetTargetAudioSource(i); 45 | if (audioSource != null) 46 | audioSource.mute = mute || !Application.isPlaying; 47 | } 48 | } 49 | 50 | videoPlayer.loopPointReached += LoopPointReached; 51 | videoPlayer.time = clipInTime; 52 | videoPlayer.Prepare(); 53 | preparing = true; 54 | } 55 | 56 | void LoopPointReached(VideoPlayer vp) 57 | { 58 | playedOnce = !loop; 59 | } 60 | 61 | public override void PrepareFrame(Playable playable, FrameData info) 62 | { 63 | if (videoPlayer == null || videoClip == null) 64 | return; 65 | 66 | videoPlayer.timeReference = Application.isPlaying ? VideoTimeReference.ExternalTime : 67 | VideoTimeReference.Freerun; 68 | 69 | if (videoPlayer.isPlaying && Application.isPlaying) 70 | videoPlayer.externalReferenceTime = playable.GetTime(); 71 | else if (!Application.isPlaying) 72 | SyncVideoToPlayable(playable); 73 | } 74 | 75 | public override void OnBehaviourPlay(Playable playable, FrameData info) 76 | { 77 | if (videoPlayer == null) 78 | return; 79 | 80 | if (!playedOnce) 81 | { 82 | PlayVideo(); 83 | SyncVideoToPlayable(playable); 84 | } 85 | } 86 | 87 | public override void OnBehaviourPause(Playable playable, FrameData info) 88 | { 89 | if (videoPlayer == null) 90 | return; 91 | 92 | if (Application.isPlaying) 93 | PauseVideo(); 94 | else 95 | StopVideo(); 96 | } 97 | 98 | public override void ProcessFrame(Playable playable, FrameData info, object playerData) 99 | { 100 | if (videoPlayer == null || videoPlayer.clip == null) 101 | return; 102 | 103 | videoPlayer.targetCameraAlpha = info.weight; 104 | 105 | if (Application.isPlaying) 106 | { 107 | for (ushort i = 0; i < videoPlayer.clip.audioTrackCount; ++i) 108 | { 109 | if (videoPlayer.audioOutputMode == VideoAudioOutputMode.Direct) 110 | videoPlayer.SetDirectAudioVolume(i, info.weight); 111 | else if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) 112 | { 113 | AudioSource audioSource = videoPlayer.GetTargetAudioSource(i); 114 | if (audioSource != null) 115 | audioSource.volume = info.weight; 116 | } 117 | } 118 | } 119 | } 120 | 121 | public override void OnGraphStart(Playable playable) 122 | { 123 | playedOnce = false; 124 | } 125 | 126 | public override void OnGraphStop(Playable playable) 127 | { 128 | if (!Application.isPlaying) 129 | StopVideo(); 130 | } 131 | 132 | public override void OnPlayableDestroy(Playable playable) 133 | { 134 | StopVideo(); 135 | } 136 | 137 | public void PlayVideo() 138 | { 139 | if (videoPlayer == null) 140 | return; 141 | 142 | videoPlayer.Play(); 143 | preparing = false; 144 | 145 | if (!Application.isPlaying) 146 | PauseVideo(); 147 | } 148 | 149 | public void PauseVideo() 150 | { 151 | if (videoPlayer == null) 152 | return; 153 | 154 | videoPlayer.Pause(); 155 | preparing = false; 156 | } 157 | 158 | public void StopVideo() 159 | { 160 | if (videoPlayer == null) 161 | return; 162 | 163 | playedOnce = false; 164 | videoPlayer.Stop(); 165 | preparing = false; 166 | } 167 | 168 | private void SyncVideoToPlayable(Playable playable) 169 | { 170 | if (videoPlayer == null || videoPlayer.clip == null) 171 | return; 172 | 173 | videoPlayer.time = (clipInTime + (playable.GetTime() * videoPlayer.playbackSpeed)) % videoPlayer.clip.length; 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /Runtime/Video/VideoPlayableBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9cbe3d1fa4843444a5eb76370a4dd15 3 | timeCreated: 1497258618 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/Video/VideoSchedulerPlayableBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Playables; 5 | 6 | namespace UnityEngine.Timeline 7 | { 8 | public sealed class VideoSchedulerPlayableBehaviour : PlayableBehaviour 9 | { 10 | private IEnumerable m_Clips; 11 | private PlayableDirector m_Director; 12 | 13 | internal PlayableDirector director 14 | { 15 | get { return m_Director; } 16 | set { m_Director = value; } 17 | } 18 | 19 | internal IEnumerable clips 20 | { 21 | get { return m_Clips; } 22 | set { m_Clips = value; } 23 | } 24 | 25 | public override void PrepareFrame(Playable playable, FrameData info) 26 | { 27 | if (m_Clips == null) 28 | return; 29 | 30 | int inputPort = 0; 31 | foreach (TimelineClip clip in m_Clips) 32 | { 33 | ScriptPlayable scriptPlayable = 34 | (ScriptPlayable)playable.GetInput(inputPort); 35 | 36 | VideoPlayableBehaviour videoPlayableBehaviour = scriptPlayable.GetBehaviour(); 37 | 38 | if (videoPlayableBehaviour != null) 39 | { 40 | double preloadTime = Math.Max(0.0, videoPlayableBehaviour.preloadTime); 41 | if (m_Director.time >= clip.start + clip.duration || 42 | m_Director.time <= clip.start - preloadTime) 43 | videoPlayableBehaviour.StopVideo(); 44 | else if (m_Director.time > clip.start - preloadTime) 45 | videoPlayableBehaviour.PrepareVideo(); 46 | } 47 | 48 | ++inputPort; 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Runtime/Video/VideoSchedulerPlayableBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6dfd332197b07004c90e572e7b383e47 3 | timeCreated: 1497258618 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/Video/VideoScriptPlayableAsset.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine.Animations; 3 | using UnityEngine.Playables; 4 | using UnityEngine.Video; 5 | 6 | namespace UnityEngine.Timeline 7 | { 8 | [Serializable] 9 | public class VideoScriptPlayableAsset : PlayableAsset 10 | { 11 | public ExposedReference videoPlayer; 12 | 13 | [SerializeField, NotKeyable] 14 | public VideoClip videoClip; 15 | 16 | [SerializeField, NotKeyable] 17 | public bool mute = false; 18 | 19 | [SerializeField, NotKeyable] 20 | public bool loop = true; 21 | 22 | [SerializeField, NotKeyable] 23 | public double preloadTime = 0.3; 24 | 25 | [SerializeField, NotKeyable] 26 | public double clipInTime = 0.0; 27 | 28 | public override Playable CreatePlayable(PlayableGraph graph, GameObject go) 29 | { 30 | ScriptPlayable playable = 31 | ScriptPlayable.Create(graph); 32 | 33 | VideoPlayableBehaviour playableBehaviour = playable.GetBehaviour(); 34 | 35 | playableBehaviour.videoPlayer = videoPlayer.Resolve(graph.GetResolver()); 36 | playableBehaviour.videoClip = videoClip; 37 | playableBehaviour.mute = mute; 38 | playableBehaviour.loop = loop; 39 | playableBehaviour.preloadTime = preloadTime; 40 | playableBehaviour.clipInTime = clipInTime; 41 | 42 | return playable; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Runtime/Video/VideoScriptPlayableAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88bb1acb4c6ce544788ae727c940bd7e 3 | timeCreated: 1497258618 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/Video/VideoScriptPlayableTrack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Playables; 5 | 6 | namespace UnityEngine.Timeline 7 | { 8 | [Serializable] 9 | [TrackClipType(typeof(VideoScriptPlayableAsset))] 10 | [TrackColor(0.008f, 0.698f, 0.655f)] 11 | public class VideoScriptPlayableTrack : TrackAsset 12 | { 13 | public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) 14 | { 15 | PlayableDirector playableDirector = go.GetComponent(); 16 | 17 | ScriptPlayable playable = 18 | ScriptPlayable.Create(graph, inputCount); 19 | 20 | VideoSchedulerPlayableBehaviour videoSchedulerPlayableBehaviour = 21 | playable.GetBehaviour(); 22 | 23 | if (videoSchedulerPlayableBehaviour != null) 24 | { 25 | videoSchedulerPlayableBehaviour.director = playableDirector; 26 | videoSchedulerPlayableBehaviour.clips = GetClips(); 27 | } 28 | 29 | return playable; 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Runtime/Video/VideoScriptPlayableTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5bef7c9d630a7042b864b59b09e597c 3 | timeCreated: 1497258618 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Runtime/com.uap.defaultplayables.runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.uap.defaultplayables.runtime", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:f06555f75b070af458a003d92f9efb00" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Runtime/com.uap.defaultplayables.runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfd171d7973349b40b5fcf659e635d18 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /VideoScriptPlayable.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UnityAssetPackages/DefaultPlayables/e1a677e83b2797d0d64aa57d7b6d55c485ce8cd2/VideoScriptPlayable.pdf -------------------------------------------------------------------------------- /VideoScriptPlayable.pdf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe111545f1755db409bc06a51d745d6b 3 | timeCreated: 1499765725 4 | licenseType: Store 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.uap.defaultplayables", 3 | "version": "1.9.0", 4 | "displayName": "Default Playables", 5 | "description": "This package includes both the Timeline Playables Wizard and a number of example Playables for you to use with Timeline.", 6 | "unity": "2020.1", 7 | "description": "See https://assetstore.unity.com/packages/essentials/default-playables-95266", 8 | "dependencies": { }, 9 | "keywords": [ 10 | "animation", 11 | "cutscene", 12 | "playable", 13 | "timeline" 14 | ], 15 | "author": { 16 | "name": "Unity Technologies" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/UnityAssetPackages/DefaultPlayables.git" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b01a64e2e75942b42a97372970420d10 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------