THE EDITOR MODE PHASE. USING THE “CNBanimAdapter” COMPONENT
Drag a “CNBAnimAdapterPrefab” to the scene or create a new “GameObject” in the scene and add a “CNBanimAdapter component” to it.
The purpose of the "EDITOR MODE" phase is twofold. Firstly, to materialize the renaming of the "AnimationClips" that we drag to the "Animations" List in the editor, based on the preset configuration in the "AnimationsSO scriptable object asset" linked in the "Anim SO" field.
Once these fields have been assigned, click on the button "ChangeAnimationClips names to adapt to AnimationsSO naming clue trees" and the first phase is finished.
Next, we provide as an example, in the first column, the images of the "AnimarionClip" of an animation pack that we want to use, and in the second column the result of renaming the clips in this first phase.
A total of 6 "AnimationClips" are categorized in the main category of "ATTACK" because it is first in the list of main categories than "CROUCH" or "JUMP" and this is how we want it to be because, "CROUCH" and "JUMP" is additional information of type "Position State" (IN-AIR, CROUCHING, DASHING, SWIMMING, CLIMBING, etc) and its utility, will be to select one or another attack depending on this additional information.
There is no magic but a robust system in which sometimes when analyzing the information, it is necessary to know how to configure which information is main and which is additional, as well as when the additional information is not consistent or deterministic enough and can cause errors (for "RIGHT" I can use "FORWARD" and "FWD", but "_F" is too weak and could lead to a categorization error by an undesired coincidence, but with too high probability of occurrence.
The second and last phase of "EDITOR MODE" has to start when we are satisfied with the result of renaming the clips and we consider that they include the basic and additional information that allows us to choose the appropriate clip at any given time. For this second phase we have the rest of the buttons in the "CNBANIMADAPTER component" editor.
GetAnimationFolderPaths tries to automatically generate the paths inside the "Resources folder" where I will find the AnimationClips" that we want to use in each model or GameObject. We will have to create the folders referenced inside "Resources" with the animations that the system expects to find in each case.
Each "RESOURCES_FOLDER_PATH" can be set manually but normally there is a main folder for each artist and several animation packs inside this main folder. The system will assign a path from the "Resources" folder resulting from adding to the variable "Main Animations Folder Folder Name In Resources" the name of each model in the "MODELS" list. Sometimes it is very useful because the artists create example "prefabs" with the same name as each folder that includes the "AnimationClips" of each pack, as in the case of the example, and other times you have to set the path manually.
![](https://primary.jwwb.nl/public/n/s/j/temp-yknyrogrkmjpszapxqcm/21-standard.png)
In the last field "ACTUALIZE_CNBANIMLINKER_COMPONENT" inside each "scriptable object" of configuration type "AnimationsSO", we created a list of "bool" variables, one for each model. It is like a selective activator/deactivator of "EASY ANIMATOR CONTROLLER". These two buttons assign "true" or "false" to all the elements in the list. When we work with many models at once or I want to make modifications that selectively affect some models, but the others I do not want to modify because we are already satisfied with the result achieved, it can be useful.
The "AddAnimLinkerComponent" button iterates all the models of the "MODELS" list inside the "scriptable object" of configuration type "AnimationsSO" that we are using and in the case that the "bool" of the "ACTUALIZE_CNBANIMLINKER_COMPONENT" list in each case has value "true", will add a "CNBAnimLinker" component to the model and initialize it by creating from the new "RUNTIMEANIMATORCONTROLLER" the states, transitions and parameters necessary for the operation of the system. It will assign this new "AnimatorController" to the "Animator component" and initialize all the required data structures. Check that in the animator component the "Avatar" field is set, in case of animating 3d models.
From this moment on, our scripts have all the necessary information to manage the animation system stored and available in data structures that we will access based on the appropriate index and not a "magic string".
The automatisms and the level of encapsulation and autonomy of the system at this point, are maximized allowing us to change the paradigm of interaction with "Mecanim". Now instead of asking "play the clip with this name or activate the parameter with this name" crossing our fingers that it exists, we will say "search in the container of this type of animation and give me the index inside the container of the one that complies with this additional information or if there is no additional information, give me the index of a random one or the index that I tell you, plus access to the transitions and parameters associated with it, to play the right clip at the right time".
![](https://primary.jwwb.nl/public/n/s/j/temp-yknyrogrkmjpszapxqcm/23-standard.png)
Crea tu propia página web con Webador