public void N80_Syntax_Fixed_LayerName_And_StatemachineNames()
        {
            string         query = "Base Layer.Alpaca.Bear.Cat";
            int            caret = 0;
            FullpathTokens ft    = new FullpathTokens();

            bool successful = FullpathSyntaxP.Fixed_LayerName_And_StatemachineNames(query, ref caret, ref ft);

            Assert.IsTrue(successful);
            Assert.AreEqual(23, caret);
            Assert.AreEqual("Base Layer", ft.LayerNameEndsWithoutDot);
            Assert.AreEqual(2, ft.StatemachineNamesEndsWithoutDot.Count);
            Assert.AreEqual("Alpaca", ft.StatemachineNamesEndsWithoutDot[0]);
            Assert.AreEqual("Bear", ft.StatemachineNamesEndsWithoutDot[1]);
        }
        public void N80_Syntax_Continued_Fixed_LayerName_And_StatemachineNames_And_StateName()
        {
            string         query = "Base Layer.Alpaca.Bear.Cat";
            int            caret = 0;
            FullpathTokens ft    = new FullpathTokens();

            // "~ Bear." まで読む
            bool successful1 = FullpathSyntaxP.Fixed_LayerName_And_StatemachineNames(query, ref caret, ref ft);

            Assert.IsTrue(successful1);

            // 続きから "Cat" まで読む
            bool successful2 = FullpathSyntaxP.Continued_Fixed_StateName(query, ref caret, ft, ref ft);

            Assert.IsTrue(successful2);
            Assert.AreEqual(26, caret);
            Assert.AreEqual("Base Layer", ft.LayerNameEndsWithoutDot);
            Assert.AreEqual(2, ft.StatemachineNamesEndsWithoutDot.Count);
            Assert.AreEqual("Alpaca", ft.StatemachineNamesEndsWithoutDot[0]);
            Assert.AreEqual("Bear", ft.StatemachineNamesEndsWithoutDot[1]);
            Assert.AreEqual("Cat", ft.StateName);
        }
Exemplo n.º 3
0
        public void ScanAnimatorController(AnimatorController ac, StringBuilder info_message)
        {
            info_message.AppendLine("Animator controller Scanning...");

            // パラメーター
            if (parameterScan)
            {
                AnimatorControllerParameter[] acpArray = ac.parameters;
                int num = 0;
                foreach (AnimatorControllerParameter acp in acpArray)
                {
                    OnParameter(num, acp);
                    num++;
                }
            }

            int lNum = 0;

            // レイヤー
            foreach (AnimatorControllerLayer layer in ac.layers)
            {
                if (OnLayer(layer, lNum))
                {
                    // フルパス, ステートマシン
                    Dictionary <string, AnimatorStateMachine> statemachineList_flat = new Dictionary <string, AnimatorStateMachine>();

                    // レイヤーは、ステートマシンを持っていないことがある。他のレイヤーのステートマシンを参照してるのだろう。

                    // 次のレイヤーへ
                    if (null == layer.stateMachine)
                    {
                        continue;
                    }

                    // 再帰をスキャンして、フラットにする。
                    ScanRecursive("", layer.stateMachine, statemachineList_flat);

                    int smNum = 0;
                    foreach (KeyValuePair <string, AnimatorStateMachine> statemachine_pair in statemachineList_flat)
                    {
                        // ステート・マシン

                        FullpathTokens ft1    = new FullpathTokens();
                        int            caret1 = 0;
                        if (!FullpathSyntaxP.Fixed_LayerName_And_StatemachineNames(statemachine_pair.Key, ref caret1, ref ft1))
                        {
                            throw new UnityException("Parse failure. [" + statemachine_pair.Key + "] ac=[" + ac.name + "]");
                        }

                        if (OnStatemachine(
                                statemachine_pair.Key,

                                // 例えばフルパスが "Base Layer.Alpaca.Bear.Cat.Dog" のとき、"Alpaca.Bear.Cat"。
                                ft1.StatemachinePath,

                                statemachine_pair.Value, lNum, smNum))
                        {
                            int sNum = 0;
                            foreach (ChildAnimatorState caState in statemachine_pair.Value.states)
                            {
                                // ステート(ラッパー)

                                if (OnState(statemachine_pair.Key, caState, lNum, smNum, sNum))
                                {
                                    // トランジション番号
                                    int tNum = 0;
                                    foreach (AnimatorStateTransition transition in caState.state.transitions)
                                    {
                                        if (OnTransition(transition, lNum, smNum, sNum, tNum))
                                        {
                                            // コンディション番号
                                            int cNum = 0;
                                            foreach (AnimatorCondition condition in transition.conditions)
                                            {
                                                OnCondition(condition, lNum, smNum, sNum, tNum, cNum);
                                                cNum++;
                                            }
                                        }
                                        tNum++;
                                    }// トランジション
                                }
                                sNum++;
                            }// ステート(ラッパー)
                        }
                        smNum++;
                    }// ステートマシン
                }
                lNum++;
            }// レイヤー

            OnScanned(info_message);
            info_message.AppendLine("Scanned.");
        }