// LOGIC

    public void Initialize(string i_DatabasePath)
    {
        tnCharactersDatabase database = Resources.Load <tnCharactersDatabase>(i_DatabasePath);

        if (database != null)
        {
            m_DefaultCharacterPrefabPath = database.defaultCharacterPrefabPath;

            for (int index = 0; index < database.charactersCount; ++index)
            {
                tnCharacterDataEntry entry = database.GetCharacterDataEntry(index);
                if (entry != null)
                {
                    string key = entry.id;
                    tnCharacterDataDescriptor descriptor = entry.descriptor;
                    if (key != "" && descriptor != null)
                    {
                        int             hash = StringUtils.GetHashCode(key);
                        tnCharacterData data = new tnCharacterData(descriptor);

                        m_Data.Add(hash, data);
                        m_Keys.Add(hash);
                    }
                }
            }
        }
        else
        {
            LogManager.LogWarning(this, "Database not loaded.");
        }
    }
Exemplo n.º 2
0
    public static void CreateAnimationPlayer()
    {
        // Load character database.

        tnCharactersDatabase characterDatabase = Resources.Load <tnCharactersDatabase>("Database/Game/CharactersDatabase");

        if (characterDatabase == null)
        {
            Debug.LogError("Character database not found.");
            return;
        }

        for (int index = 0; index < characterDatabase.charactersCount; ++index)
        {
            tnCharacterDataEntry entry = characterDatabase.GetCharacterDataEntry(index);
            if (entry != null)
            {
                EditorUtility.DisplayProgressBar("Processing", "Processing Animator for " + entry.id + "...", Mathf.Clamp01((float)index / characterDatabase.charactersCount));

                tnCharacterDataDescriptor descriptor = entry.descriptor;
                if (descriptor != null)
                {
                    SerializedObject serializedDescriptor = new SerializedObject(descriptor);

                    SerializedProperty serializedProperty = serializedDescriptor.FindProperty("m_AnimatorController");
                    serializedProperty.objectReferenceValue = CreateAnimatorController(entry.id, entry.descriptor);

                    serializedDescriptor.ApplyModifiedProperties();
                }
            }
        }

        AssetDatabase.SaveAssets();

        EditorUtility.ClearProgressBar();
    }