Exemplo n.º 1
0
    void CreateAnimation(ref TAnim anim, string animName, AnimSprite animSheet)
    {
        TinkerAnimation[] directionAnimations = new TinkerAnimation[4] {
            new TinkerAnimation(), new TinkerAnimation(), new TinkerAnimation(), new TinkerAnimation()
        };
        string[] dirs = new string[4] {
            "FORWARD", "RIGHT", "BACK", "LEFT"
        };
        string gender_prefix = gender == GENDER.MALE ? "M" : "F";
        string gender_name   = gender == GENDER.MALE ? "Male" : "Female";

        rootDirectory += itemName;
        string constPath = rootDirectory + gender_name;

        string initPath = constPath + "/" + itemName + " " + gender_prefix + "/" + animName + "/" + itemName + "_" + animName.ToUpper();

        if (!AssetDatabase.IsValidFolder("Assets/" + constPath + "/" + itemName + " " + gender_prefix))
        {
            AssetDatabase.CreateFolder("Assets/" + constPath, itemName + " " + gender_prefix);
        }

        if (!AssetDatabase.IsValidFolder("Assets/" + constPath + "/" + itemName + " " + gender_prefix + "/" + animName))
        {
            AssetDatabase.CreateFolder("Assets/" + constPath + "/" + itemName + " " + gender_prefix, animName);
        }

        anim.anims = new TinkerAnimation[4];
        // Creates animation file for each facing direction
        for (int i = 0; i < directionAnimations.Length; i++)
        {
            directionAnimations[i].loop = true;
            directionAnimations[i].timeBetweenFrames = 0.2f;

            directionAnimations[i].sprites = new Sprite[animSheet.frames];

            // Loop through all our sprites
            for (int a = 0; a < animSheet.frames; a++)
            {
                directionAnimations[i].sprites[a] = animSheet.sprite[i + (a * 4)];
            }

            ScriptableObjectUtility.CreateAsset <TinkerAnimation>(directionAnimations[i], initPath + "ANIM_" + gender_prefix + "_" + dirs[i]);
            //anim.anims[i] = (TinkerAnimation)Resources.Load(initPath + "ANIM_"+ gender_prefix + "_" + dirs[i]);
            anim.anims[i] = directionAnimations[i];
        }

        ScriptableObjectUtility.CreateAsset <TAnim>(anim, initPath + "_" + gender_prefix);
        AssetDatabase.Refresh();
    }
Exemplo n.º 2
0
    void CreateAnimation(string animName, AnimSprite animSheet)
    {
        TinkerAnimation animation = new TinkerAnimation();

        string finalPath = "Assets/" + rootDirectory + "/" + animName;

        if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory))
        {
            AssetDatabase.CreateFolder("Assets", rootDirectory);
        }
        if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory + "/" + animName))
        {
            AssetDatabase.CreateFolder("Assets/" + rootDirectory, animName);
        }

        animation.loop = true;
        animation.timeBetweenFrames = 0.2f;
        animation.sprites           = animSheet.sprite;

        ScriptableObjectUtility.CreateAsset <TinkerAnimation>(animation, rootDirectory + "/" + animName + "/ANIM_" + animName + "_" + itemName);
    }
Exemplo n.º 3
0
    void CreateAnimation(ref TAnim anim, string animName, AnimSprite animSheet)
    {
        TinkerAnimation[] directionAnimations = new TinkerAnimation[4] {
            new TinkerAnimation(), new TinkerAnimation(), new TinkerAnimation(), new TinkerAnimation()
        };
        string[] dirs = new string[4] {
            "FORWARD", "RIGHT", "BACK", "LEFT"
        };
        string finalPath = "";

        if (groupName.Length > 0)
        {
            finalPath = rootDirectory + "/" + groupName + "/" + animName;
        }
        else
        {
            finalPath = rootDirectory + "/" + animName;
        }


        if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory))
        {
            AssetDatabase.CreateFolder("Assets", rootDirectory);
        }
        if (groupName.Length > 0)
        {
            if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory + "/" + groupName))
            {
                AssetDatabase.CreateFolder("Assets/" + rootDirectory, groupName);
            }
            if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory + "/" + groupName + "/" + animName))
            {
                AssetDatabase.CreateFolder("Assets/" + rootDirectory + "/" + groupName, animName);
            }
        }
        else
        {
            if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory + "/" + animName))
            {
                AssetDatabase.CreateFolder("Assets/" + rootDirectory, animName);
            }
        }

        anim.anims = new TinkerAnimation[4];
        // Creates animation file for each facing direction
        for (int i = 0; i < directionAnimations.Length; i++)
        {
            directionAnimations[i].loop = animSheet.loop;
            directionAnimations[i].timeBetweenFrames = 0.2f;

            directionAnimations[i].sprites = new Sprite[animSheet.frames];

            // Loop through all our sprites
            for (int a = 0; a < animSheet.frames; a++)
            {
                directionAnimations[i].sprites[a] = animSheet.sprite[i + (a * 4)];
            }

            ScriptableObjectUtility.CreateAsset <TinkerAnimation>(directionAnimations[i], finalPath + "/ANIM_" + itemName + "_" + dirs[i]);
            //anim.anims[i] = (TinkerAnimation)Resources.Load(initPath + "ANIM_"+ gender_prefix + "_" + dirs[i]);
            anim.anims[i] = directionAnimations[i];
        }
        ScriptableObjectUtility.CreateAsset <TAnim>(anim, finalPath + "/" + itemName + "_" + animName);
        AssetDatabase.Refresh();
    }