Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        if (!uiController)
        {
            uiController = FindObjectOfType <VrmUiController>();
        }

        if (!cameraController)
        {
            cameraController = FindObjectOfType <CameraController>();
            if (cameraController)
            {
                originalWheelMode = cameraController.zoomMode;
            }
        }

        if (!audioSource)
        {
            audioSource = FindObjectOfType <AudioSource>();
        }

        // Load the initial model.
        string[] cmdArgs = System.Environment.GetCommandLineArgs();
        if (cmdArgs.Length > 1)
        {
            LoadModel(cmdArgs[1]);
        }
        else
        {
            LoadModel(Application.streamingAssetsPath + "/default_vrm.vrm");
        }

        // Load the initial motion.
        LoadMotion(Application.streamingAssetsPath + "/default_bvh.txt");

        // Initialize window manager
        windowController = FindObjectOfType <WindowController>();
        if (windowController)
        {
            // Add a file drop handler.
            windowController.OnFilesDropped += Window_OnFilesDropped;
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        if (!targetObject)
        {
            targetObject       = new GameObject("LookAtTarget");
            hasNewTargetObject = true;
        }

        lookAtHead      = GetComponent <VRMLookAtHead>();
        blendShapeProxy = GetComponent <VRMBlendShapeProxy>();

        if (lookAtHead)
        {
            lookAtHead.Target     = targetObject.transform;
            lookAtHead.UpdateType = UpdateType.LateUpdate;

            headTransform = lookAtHead.Head;
        }
        if (!headTransform)
        {
            headTransform = this.transform;
        }

        // マウスカーソルとの奥行きに反映させるためカメラを取得
        if (!currentCamera)
        {
            currentCamera = Camera.main;
        }

        // UIコントローラーを取得
        if (!uiController)
        {
            uiController = FindObjectOfType <VrmUiController>();
        }

        SetAnimator(GetComponent <Animator>());

        currentState  = animator.GetCurrentAnimatorStateInfo(0);
        previousState = currentState;
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        // 指定がなければ自動で探す
        if (!uiController)
        {
            uiController = FindObjectOfType <VrmUiController>();
        }
        uiController.enableRandomMotion  = true;
        uiController.enableRandomEmotion = true;
        if (uiController.motionToggleRandom)
        {
            uiController.motionToggleRandom.onValueChanged.AddListener(val => SetRandomMotion(val));
        }
        if (uiController.faceToggleRandom)
        {
            uiController.faceToggleRandom.onValueChanged.AddListener(val => SetRandomEmotion(val));
        }

        // 指定がなければ自動で探す
        if (!canvas)
        {
            canvas = FindObjectOfType <Canvas>();
        }

        // 指定がなければ自動で探す
        if (!cameraController)
        {
            cameraController = FindObjectOfType <CameraController>();
            if (cameraController)
            {
                originalWheelMode = cameraController.zoomMode;
            }
        }

        // 指定がなければ自動で探す
        if (!audioSource)
        {
            audioSource = FindObjectOfType <AudioSource>();
        }

        // Load the initial model.
        LoadModel(Application.streamingAssetsPath + "/default_vrm.vrm");

        //// 引数でオプションが渡る場合の処理が面倒なため、引数でモデル指定は無しとする
        //string[] cmdArgs = System.Environment.GetCommandLineArgs();
        //if (cmdArgs.Length > 1)
        //{
        //	LoadModel(cmdArgs[1]);
        //} else
        //{
        //	LoadModel(Application.streamingAssetsPath + "/default_vrm.vrm");
        //}

        // Load the initial motion.
        LoadMotion(Application.streamingAssetsPath + "/default_bvh.txt");

        // Initialize window manager
        windowController = FindObjectOfType <WindowController>();
        if (windowController)
        {
            // Add a file drop handler.
            windowController.OnFilesDropped += Window_OnFilesDropped;

            if (uiController && uiController.openButton)
            {
                uiController.openButton.onClick.AddListener(() =>
                {
                    string path = windowController.ShowOpenFileDialog("VRM file|*.vrm|Motion file|*.bvh|Audio file|*.wav;*.ogg|All file|*.*");
                    LoadFile(path);
                });
            }
        }
    }