示例#1
0
    private NetworkCharacter createCharacter(uint udid, bool isMine = false)
    {
        GameObject       characterPrefab  = null;
        NetworkCharacter networkCharacter = null;

        try {
            if (lipSyncSolution == ELipSyncSolution.OculusSolution)
            {
                characterPrefab = Resources.Load <GameObject>("Character");
            }
            else if (lipSyncSolution == ELipSyncSolution.SalsaSolution)
            {
                characterPrefab = Resources.Load <GameObject>("Ethan");
            }
        }
        catch (Exception e) {
            Debug.LogError("can not load character from resources");
            return(null);
        }

        if (isMine)
        {
            GameObject characterObj = Instantiate(characterPrefab, startPoint);

            characterObj.SetActive(true);

            characterObj.transform.localPosition = Vector3.zero;
            characterObj.transform.localRotation = Quaternion.identity;

            networkCharacter = characterObj.GetComponent <NetworkCharacter>();
            _mainCharacter   = networkCharacter;

            networkCharacter.initCharacter(udid, true);
        }
        else
        {
            GameObject characterObj = null;

            if (lipSyncSolution == ELipSyncSolution.OculusSolution)
            {
                characterObj = Instantiate(characterPrefab, startPoint3);
            }
            else if (lipSyncSolution == ELipSyncSolution.SalsaSolution)
            {
                characterObj = Instantiate(characterPrefab, startPoint2);
            }

            characterObj.SetActive(true);

            if (characterObj == null)
            {
                Debug.LogError("this lip sync solution is not implemented");
            }

            characterObj.transform.localPosition = Vector3.zero;
            characterObj.transform.localRotation = Quaternion.Euler(0, 180, 0);

            networkCharacter = characterObj.GetComponent <NetworkCharacter>();

            _networkCharacterList.Add(networkCharacter);

            networkCharacter.initCharacter(udid);
        }

        return(networkCharacter);
    }