static List <ConstGenSettings.ParamsCTRLR> RetriveValues() { // find controller GUIDs and create LayersCTRLR list string[] controllers = AssetDatabase.FindAssets("t:animatorcontroller"); List <ConstGenSettings.ParamsCTRLR> animCTRLRS = new List <ConstGenSettings.ParamsCTRLR>(); foreach (string CTRLR in controllers) { // get controller and it's path string path = AssetDatabase.GUIDToAssetPath(CTRLR); UnityEditor.Animations.AnimatorController item = AssetDatabase.LoadAssetAtPath <UnityEditor.Animations.AnimatorController>(path); if (item.parameters.Length == 0) { continue; } ConstGenSettings.ParamsCTRLR controller = new ConstGenSettings.ParamsCTRLR(); controller.name = item.name; // loop through controller's parameters and cache it foreach (var parameter in item.parameters) { controller.parameters.Add(parameter.name); } animCTRLRS.Add(controller); } return(animCTRLRS); }
/// <summary> /// checks if there is any changes on the constants /// </summary> private static void UpdateFile() { if (Application.isPlaying) { return; } bool generate = false; instance.newParameters = RetriveValues(); // check if the number of animation controllers in the assets has changed if (instance.oldParameters.Count != instance.newParameters.Count) { generate = true; } else // else check for changes in the parameters of the controllers { // loop through animators for (int i = 0; i < instance.oldParameters.Count; i++) { ConstGenSettings.ParamsCTRLR oldCTRLR = instance.oldParameters[i]; ConstGenSettings.ParamsCTRLR newCTRLR = instance.newParameters[i]; // check if the name of the controller has changed or // if any parameters is added or removed if (oldCTRLR.name != newCTRLR.name || oldCTRLR.parameters.Count != newCTRLR.parameters.Count) { generate = true; break; } else // else check if any of the name of paramters has changed { // loop through parameters for (int i2 = 0; i2 < oldCTRLR.parameters.Count; i2++) { string oldName = oldCTRLR.parameters[i2]; string newName = newCTRLR.parameters[i2]; // compare parameter names if (oldName != newName) { generate = true; break; } } } if (generate) // break out of animators loop { break; } } } if (generate) { Generate(); } }