コード例 #1
0
    private void OnGUI()
    {
        GUI.color = Color.white;
        GUILayout.BeginArea(_dropDownRectAgents.DdRect);
        GUILayout.Label("Character");
        _dropDownRectAgents.DdList = _agentScripts.Select(s => s.CharacterName).ToList();
        _agentSelInd = _dropDownRectAgents.ShowDropDownRect();

        GUILayout.EndArea();


        GUILayout.BeginArea(_dropDownRectAnimNames.DdRect);
        GUILayout.Label("Animation");
        _dropDownRectAnimNames.DdList = _agentScripts[_agentSelInd].AnimNames.ToList();
        int ind = _dropDownRectAnimNames.ShowDropDownRect();

        _agentScripts[_agentSelInd].AnimName = _agentScripts[_agentSelInd].AnimNames[ind];
        GUILayout.EndArea();


        GUILayout.BeginArea(new Rect(5, 20, 105, Screen.height));


        GUILayout.Label("Personality");
        GUI.color = Color.white;

        GUILayout.Label("");
        for (int i = 0; i < 5; i++)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("" + _persMin);
            GUILayout.Label("" + _personalityName[i]);
            GUILayout.Label("" + _persMax);
            GUILayout.EndHorizontal();

            _personality[i] = _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[i];
            GUI.color       = Color.white;



            GUI.backgroundColor = Color.white;
            _personality[i]     = GUILayout.HorizontalSlider(_personality[i], _persMin, _persMax).Truncate(1);

            //Assign agent personality
            _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[i] = _personality[i];


            string[] ocean = { "O", "C", "E", "A", "N" };
            for (int j = 0; j < 5; j++)
            {
                if (_agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[j] == -1)
                {
                    ocean[j] += "-";
                }
                else if (_agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[j] == 1)
                {
                    ocean[j] += "+";
                }
                else
                {
                    ocean[j] = "";
                }
            }


            /*
             * _agentSel.AgentText.text = string.Format(ocean[0] + "  " + ocean[1] + "  " + ocean[2] + "  " + ocean[3] + "  " + ocean[4]);
             *
             *
             * _agentSel.AgentText.text += string.Format("\nS: {0:0.00} W: {1:0.00} T: {2:0.00} F: {3:0.00}", _agentSel.Effort[0], _agentSel.Effort[1], _agentSel.Effort[2], _agentSel.Effort[3]);
             */
        }


        GUI.color = Color.white;


        _lockHand = GUILayout.Toggle(_lockHand, "Lock hand");
        foreach (AnimationInfo a in _agentScripts)
        {
            a.GetComponent <IKAnimator>().LockHand = _lockHand;
        }



        if (_driveParams[31].DrivesAchieved)
        {
            if (GUILayout.Button("Reset scene"))
            {
                Application.LoadLevel(Application.loadedLevel);
            }
            if (GUILayout.Button("Randomize"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = MathDefs.GetRandomNumber(-1f, 1f);
                    }
                }
            }
            if (GUILayout.Button("Reset"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = 0;
                    }
                }
            }
            if (GUILayout.Button("Assign All"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = _personality[i];
                    }
                }
            }
            if (GUILayout.Button("Assign All Variation"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = _personality[i] +
                                                                                 MathDefs.GetRandomNumber(-0.2f, 0.2f);
                        if (a.GetComponent <PersonalityComponent>().Personality[i] > 1)
                        {
                            a.GetComponent <PersonalityComponent>().Personality[i] = 1;
                        }
                        else if (a.GetComponent <PersonalityComponent>().Personality[i] < -1)
                        {
                            a.GetComponent <PersonalityComponent>().Personality[i] = -1;
                        }
                    }
                }
            }
            if (GUILayout.Button("Play"))
            {
                PlayAgents();
            }

            if (GUILayout.Button("Record"))
            {
                GameObject.Find("Main Camera").GetComponent <Screenshot>().IsRunning = true;

                Time.timeScale = 0.25f;



                PlayAgents();
            }



            //we need to update after play because playanim resets torso parameters for speed etc. when animinfo is reset
        }

        GUI.color = Color.yellow;
        GUILayout.Label("S:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[0] + " W:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[1] + " T:" +
                        _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[2] + " F:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[3]);

        GUILayout.EndArea();
    }
コード例 #2
0
    private void OnGUI()
    {
        GUI.skin = ButtonSkin;


        bool disableBefore = DisableLMA;

        DisableLMA = GUILayout.Toggle(DisableLMA, "Disable LMA");

        if (disableBefore != DisableLMA)      //a change has been made in the toggle
        {
            foreach (AnimationInfo a in _agentScripts)
            {
                a.DisableLMA = DisableLMA;
            }
        }



        GUI.color = Color.white;
        GUILayout.BeginArea(_dropDownRectAgents.DdRect);
        GUILayout.Label("Character");
        _dropDownRectAgents.DdList = _agentScripts.Select(s => s.CharacterName).ToList();
        _agentSelInd = _dropDownRectAgents.ShowDropDownRect();
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(5, 20, 105, Screen.height));


        GUILayout.Label("Personality");
        GUI.color = Color.white;

        GUILayout.Label("");
        for (int i = 0; i < 5; i++)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("" + _persMin);
            GUILayout.Label("" + _personalityName[i]);
            GUILayout.Label("" + _persMax);
            GUILayout.EndHorizontal();

            _personality[i] = _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[i];
            GUI.color       = Color.white;



            GUI.backgroundColor = Color.white;
            _personality[i]     = GUILayout.HorizontalSlider(_personality[i], _persMin, _persMax).Truncate(1);

            //Assign agent personality
            _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[i] = _personality[i];


            string[] ocean = { "O", "C", "E", "A", "N" };
            for (int j = 0; j < 5; j++)
            {
                if (_agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[j] == -1)
                {
                    ocean[j] += "-";
                }
                else if (_agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[j] == 1)
                {
                    ocean[j] += "+";
                }
                else
                {
                    ocean[j] = "";
                }
            }
        }


        GUI.color = Color.white;



        if (_driveParams[31].DrivesAchieved)
        {
            if (GUILayout.Button("Reset scene"))
            {
                Application.LoadLevel(Application.loadedLevel);
            }
            if (GUILayout.Button("Randomize"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = MathDefs.GetRandomNumber(-1f, 1f);
                    }
                }
            }
            if (GUILayout.Button("Reset"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = 0;
                    }
                }
            }
            if (GUILayout.Button("Assign All"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = _personality[i];
                    }
                }
            }
            if (GUILayout.Button("Play"))
            {
                _walkIsOver = 0;
                int agentInd = 0;
                foreach (AnimationInfo t in _agentScripts)
                {
                    t.AnimName = "walking";

                    ResetComponents(t);


                    _persMapper.MapPersonalityToMotion(t.GetComponent <PersonalityComponent>()); //calls initkeypoints, which stops the animation
                    Play(t);

                    GUI.color = Color.white;
                    agentInd++;
                }
            }

            if (GUILayout.Button("Record"))
            {
                _walkIsOver = 0;

                GameObject.Find("Camera").GetComponent <Screenshot>().IsRunning = true;

                Time.timeScale = 0.5f;

                int agentInd = 0;

                foreach (AnimationInfo t in _agentScripts)
                {
                    t.AnimName = "walking";

                    ResetComponents(t);


                    _persMapper.MapPersonalityToMotion(t.GetComponent <PersonalityComponent>()); //calls initkeypoints, which stops the animation
                    Play(t);

                    GUI.color = Color.white;
                    agentInd++;
                }
            }



            //we need to update after play because playanim resets torso parameters for speed etc. when animinfo is reset
        }

        GUI.color = Color.yellow;
        GUILayout.Label("S:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[0] + " W:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[1] + " T:" +
                        _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[2] + " F:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[3]);

        GUILayout.EndArea();
    }
コード例 #3
0
    private void OnGUI()
    {
        GUI.skin = ButtonSkin;


        bool disableBefore = DisableLMA;

        DisableLMA = GUILayout.Toggle(DisableLMA, "Disable LMA");

        if (disableBefore != DisableLMA)      //a change has been made in the toggle
        {
            foreach (AnimationInfo a in _agentScripts)
            {
                a.DisableLMA = DisableLMA;
            }
        }



        GUI.color = Color.white;
        GUILayout.BeginArea(_dropDownRectAgents.DdRect);
        GUILayout.Label("Character");
        _dropDownRectAgents.DdList = _agentScripts.Select(s => s.CharacterName).ToList();
        _agentSelInd = _dropDownRectAgents.ShowDropDownRect();

        GUILayout.EndArea();


        GUILayout.BeginArea(_dropDownRectAnimNames.DdRect);
        GUILayout.Label("Animation");
        _dropDownRectAnimNames.DdList = _agentScripts[_agentSelInd].AnimNames.ToList();
        int ind = _dropDownRectAnimNames.ShowDropDownRect();

        _agentScripts[_agentSelInd].AnimName = _agentScripts[_agentSelInd].AnimNames[ind];
        GUILayout.EndArea();

        GUILayout.BeginArea(_dropDownRectNationality.DdRect);
        GUILayout.Label("Nationality");
        _dropDownRectNationality.DdList = _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().listNationality();
        int ind_nationality = _dropDownRectNationality.ShowDropDownRect();

        nationality_s = _dropDownRectNationality.DdList[ind_nationality];
        _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Culture = nationality_s;
        GUILayout.EndArea();

        GUILayout.BeginArea(_dropDownRectProfession.DdRect);
        GUILayout.Label("Profession");
        _dropDownRectProfession.DdList = _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().listProfession();
        int ind_profession = _dropDownRectProfession.ShowDropDownRect();

        profession_s = _dropDownRectProfession.DdList[ind_profession];
        _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Profession = profession_s;
        GUILayout.EndArea();



        GUILayout.BeginArea(new Rect(5, 20, 105, Screen.height));


        GUILayout.Label("Personality");
        GUI.color = Color.white;

        GUILayout.Label("");
        for (int i = 0; i < 5; i++)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("" + _persMin);
            GUILayout.Label("" + _personalityName[i]);
            GUILayout.Label("" + _persMax);
            GUILayout.EndHorizontal();

            _personality[i] = _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[i];
            GUI.color       = Color.white;



            GUI.backgroundColor = Color.white;
            _personality[i]     = GUILayout.HorizontalSlider(_personality[i], _persMin, _persMax).Truncate(1);

            //Assign agent personality
            _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[i] = _personality[i];


            string[] ocean = { "O", "C", "E", "A", "N" };
            for (int j = 0; j < 5; j++)
            {
                if (_agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[j] == -1)
                {
                    ocean[j] += "-";
                }
                else if (_agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Personality[j] == 1)
                {
                    ocean[j] += "+";
                }
                else
                {
                    ocean[j] = "";
                }
            }


            /*
             * _agentSel.AgentText.text = string.Format(ocean[0] + "  " + ocean[1] + "  " + ocean[2] + "  " + ocean[3] + "  " + ocean[4]);
             *
             *
             * _agentSel.AgentText.text += string.Format("\nS: {0:0.00} W: {1:0.00} T: {2:0.00} F: {3:0.00}", _agentSel.Effort[0], _agentSel.Effort[1], _agentSel.Effort[2], _agentSel.Effort[3]);
             */
        }


        GUI.color = Color.white;


        _lockHand = GUILayout.Toggle(_lockHand, "Lock hand");
        foreach (AnimationInfo a in _agentScripts)
        {
            a.GetComponent <IKAnimator>().LockHand = _lockHand;
        }


        GUILayout.BeginHorizontal();
        GUILayout.Label("" + 0);
        GUILayout.Label("W");
        GUILayout.Label("" + 1);
        GUILayout.EndHorizontal();
        GUI.color           = Color.white;
        GUI.backgroundColor = Color.white;
        n_p_weight          = GUILayout.HorizontalSlider(n_p_weight, 0, 1).Truncate(1);
        if (n_p_weight != prev_n_p_weight)
        {
            prev_n_p_weight = n_p_weight;
            foreach (AnimationInfo a in _agentScripts)
            {
                a.GetComponent <PersonalityComponent>().BlendWeight = n_p_weight;
            }
        }
        if (_driveParams[31].DrivesAchieved)
        {
            if (GUILayout.Button("Reset scene"))
            {
                Application.LoadLevel(Application.loadedLevel);
            }
            if (GUILayout.Button("Randomize"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = MathDefs.GetRandomNumber(-1f, 1f);
                    }
                }
            }
            if (GUILayout.Button("Reset"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = 0;
                    }
                }
            }
            if (GUILayout.Button("Assign All"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = _personality[i];
                    }
                    //will cause small diff in ocean values if I do this, for unknown reasons: so I comment this out
                    //a.GetComponent<PersonalityComponent>().Culture = nationality_s;
                    //a.GetComponent<PersonalityComponent>().Profession = profession_s;
                }
            }
            if (GUILayout.Button("Assign All Variation"))
            {
                foreach (AnimationInfo a in _agentScripts)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        a.GetComponent <PersonalityComponent>().Personality[i] = _personality[i] +
                                                                                 MathDefs.GetRandomNumber(-0.2f, 0.2f);
                        if (a.GetComponent <PersonalityComponent>().Personality[i] > 1)
                        {
                            a.GetComponent <PersonalityComponent>().Personality[i] = 1;
                        }
                        else if (a.GetComponent <PersonalityComponent>().Personality[i] < -1)
                        {
                            a.GetComponent <PersonalityComponent>().Personality[i] = -1;
                        }
                    }
                }
            }
            if (GUILayout.Button("Play"))
            {
                int agentInd = 0;



                foreach (AnimationInfo t in _agentScripts)
                {
                    ResetComponents(t);


                    _persMapper.MapPersonalityToMotion(t.GetComponent <PersonalityComponent>()); //calls initkeypoints, which stops the animation

                    Play(t);

                    GUI.color = Color.white;
                    agentInd++;
                }
                _persMapper.MapAnimSpeeds(_agentScripts, 0.9f, 1.3f); //map them to the range
            }

            if (GUILayout.Button("Record"))
            {
                GameObject.Find("Camera").GetComponent <Screenshot>().IsRunning = true;

                Time.timeScale = 0.25f;

                int agentInd = 0;
                foreach (AnimationInfo t in _agentScripts)
                {
                    ResetComponents(t);


                    _persMapper.MapPersonalityToMotion(t.GetComponent <PersonalityComponent>()); //calls initkeypoints, which stops the animation
                    Play(t);

                    GUI.color = Color.white;
                    agentInd++;
                }


                _persMapper.MapAnimSpeeds(_agentScripts, 0.9f, 1.3f); //map them to the range
            }



            //we need to update after play because playanim resets torso parameters for speed etc. when animinfo is reset
        }

        GUI.color = Color.yellow;
        GUILayout.Label("S:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[0] + " W:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[1] + " T:" +
                        _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[2] + " F:" + _agentScripts[_agentSelInd].GetComponent <PersonalityComponent>().Effort[3]);

        GUILayout.EndArea();
    }