static string GetSaveControllerPath(SelectableHelper target) { var defaultName = target.gameObject.name; var message = string.Format("Create a new animator for the game object '{0}':", defaultName); return(EditorUtility.SaveFilePanelInProject("New Animation Contoller", defaultName, "controller", message)); }
static AnimatorController GenerateSelectableAnimatorContoller(AnimationTriggers animationTriggers, SelectableHelper target) { if (target == null) { return(null); } var path = GetSaveControllerPath(target); if (string.IsNullOrEmpty(path)) { return(null); } var normalName = string.IsNullOrEmpty(animationTriggers.normalTrigger) ? "Normal" : animationTriggers.normalTrigger; var highlightedName = string.IsNullOrEmpty(animationTriggers.highlightedTrigger) ? "Highlighted" : animationTriggers.highlightedTrigger; var pressedName = string.IsNullOrEmpty(animationTriggers.pressedTrigger) ? "Pressed" : animationTriggers.pressedTrigger; var disabledName = string.IsNullOrEmpty(animationTriggers.disabledTrigger) ? "Disabled" : animationTriggers.disabledTrigger; var controller = AnimatorController.CreateAnimatorControllerAtPath(path); GenerateTriggerableTransition(normalName, controller); GenerateTriggerableTransition(highlightedName, controller); GenerateTriggerableTransition(pressedName, controller); GenerateTriggerableTransition(disabledName, controller); return(controller); }