private void HandleInitialization(bool isGUICall) { if (scriptReloadChecker == null) { // Unity persists some objects through reload, and fails to persist others. This makes it hard to figure out if // something needs to be re-cached. This solves that - we know that Unity can't persist a raw object, so if it's null, a reload is neccessary. scriptReloadChecker = new object(); metaDataDrawer = new MetaDataDrawer(animationPlayer); stylesCreated = false; transitionsNeedsUpdate = true; MarkDirty(); } if (isGUICall && !stylesCreated) { var backgroundTex = EditorUtilities.MakeTex(1, 1, new Color(1.0f, 1.0f, 1.0f, .1f)); editLayerStyle = new GUIStyle { normal = { background = backgroundTex } }; var buttonBackgroundTex = EditorUtilities.MakeTex(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.05f)); var buttonSelectedTex = EditorUtilities.MakeTex(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.05f)); var buttonNotSelectedText = EditorUtilities.MakeTex(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.2f)); editLayerButton_Background = new GUIStyle { normal = { background = buttonBackgroundTex } }; editLayerButton_NotSelected = new GUIStyle(GUI.skin.label) { normal = { background = buttonNotSelectedText }, alignment = TextAnchor.MiddleCenter }; editLayerButton_Selected = new GUIStyle(GUI.skin.label) { normal = { background = buttonSelectedTex }, alignment = TextAnchor.MiddleCenter }; stylesCreated = true; } if (animationPlayer.layers == null || animationPlayer.layers.Length == 0) { animationPlayer.layers = new AnimationLayer[1]; animationPlayer.layers[0] = AnimationLayer.CreateLayer(); if (animationPlayer.defaultTransition == default(TransitionData)) { animationPlayer.defaultTransition = TransitionData.Linear(.1f); //default shouldn't be snap } return; } if (stateNamesNeedsUpdate) { stateNamesNeedsUpdate = false; allStateNames = new string[animationPlayer.layers.Length][]; for (int i = 0; i < animationPlayer.layers.Length; i++) { var states = animationPlayer.layers[i].states; allStateNames[i] = new string[states.Count]; for (int j = 0; j < states.Count; j++) { allStateNames[i][j] = states[j].Name; } } } if (transitionsNeedsUpdate) { transitionsNeedsUpdate = false; foreach (var layer in animationPlayer.layers) { foreach (var transition in layer.transitions) { transition.FetchStates(layer.states); } } } if (previewer == null) { previewer = new AnimationStatePreviewer(animationPlayer); } }