Exemplo n.º 1
0
    /// <summary>
    /// アクティブの情報出力
    /// </summary>
    private void LipSyncExport()
    {
        string tmpPath    = Path.Combine(Application.dataPath, "ExpansionTools/LipSyncSelect/tmp/ClassTemplate.cs.template");
        string exportText = BearFileUtil.GetAllText(tmpPath);


        VRC_AvatarDescriptor avatarDescriptor = GetVRCAvatarDescriptor();

        if (avatarDescriptor.lipSync == VRC_AvatarDescriptor.LipSyncStyle.VisemeBlendShape)
        {
            var visemeBlendShapes = avatarDescriptor.VisemeBlendShapes;

            List <string> blendShapeNames = GetBlendShapeNames();
            for (int i = 0; i < visemeBlendShapes.Length; i++)
            {
                string[] matchNames = blendShapeNames.Where(t => t == visemeBlendShapes[i]).ToArray();
                if (0 < matchNames.Length)
                {
                    string replaceKey = "@" + ((VRC_AvatarDescriptor.Viseme)i).ToString() + "@";
                    exportText = exportText.Replace(replaceKey, matchNames[0]);
                }
            }
        }
        var exportWindow = EditorWindow.GetWindow <LipSyncExport>(true);

        exportWindow.exportText = exportText;
        exportWindow.position   = new Rect(200f, 200f, 300f, 100f);
    }
Exemplo n.º 2
0
    public static void addLipSync(GameObject avatar)
    {
        VRC_AvatarDescriptor vrcad = avatar.GetComponent <VRC_AvatarDescriptor>();

        SkinnedMeshRenderer[] meshes = avatar.GetComponentsInChildren <SkinnedMeshRenderer>();
        if (meshes.Length > 0)
        {
            vrcad.VisemeSkinnedMesh = meshes[0];
            vrcad.lipSync           = VRC_AvatarDescriptor.LipSyncStyle.VisemeBlendShape;

            SkinnedMeshRenderer head = meshes[0];
            Mesh     m           = head.sharedMesh;
            string[] blendshapes = { "sil", "pp", "ff", "th", "dd", "kk", "ch", "ss", "nn", "rr", "aa", "_e", "ih", "oh", "ou" };
            string[] appliedbss  = { "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-", "-none-" };
            for (int i = 0; i < m.blendShapeCount; i++)
            {
                string name = m.GetBlendShapeName(i);
                for (int ii = 0; ii < blendshapes.Length; ii++)
                {
                    if (name.Contains(blendshapes[ii]))
                    {
                        appliedbss[ii] = name;
                    }
                }
            }
            if (m.blendShapeCount >= 14)
            {
                vrcad.VisemeBlendShapes = appliedbss;
            }
            else
            {
                vrcad.lipSync = VRC_AvatarDescriptor.LipSyncStyle.Default;
            }
        }
    }
Exemplo n.º 3
0
        public void LoadAvatarInfo(VRC_AvatarDescriptor descriptor)
        {
            if (descriptor == null)
            {
                return;
            }
            Descriptor = descriptor;

            StandingAnimController = Descriptor.CustomStandingAnims;
            SittingAnimController  = Descriptor.CustomSittingAnims;

            AnimSavedFolderPath = GetAnimSavedFolderPath(StandingAnimController);
            FaceMesh            = Descriptor.VisemeSkinnedMesh;

            if (FaceMesh != null && Descriptor.lipSync == LipSyncStyle.VisemeBlendShape)
            {
                LipSyncShapeKeyNames = new List <string>();
                LipSyncShapeKeyNames.AddRange(Descriptor.VisemeBlendShapes);
            }

            LipSyncStyle = Descriptor.lipSync;

            EyePos = Descriptor.ViewPosition;
            Sex    = Descriptor.Animations;

            base.LoadAvatarInfo(Descriptor.gameObject);
        }
Exemplo n.º 4
0
    // Token: 0x06005004 RID: 20484 RVA: 0x001B5638 File Offset: 0x001B3A38
    public void Finalize(Animator animator, VRC_AvatarDescriptor Ad, bool local)
    {
        VRC_AnimationController component = base.GetComponent <VRC_AnimationController>();

        component.Reset(animator, Ad);
        if (animator.isHuman)
        {
            if (this.avatarManager != null && this.player != null)
            {
                this.Push(this.avatarManager.GetStandAnimController());
                if (this.avatarAnimation != null && this.avatarAnimation.motionState.IsSeated && this.player.currentStation != null)
                {
                    this.player.currentStation.ApplySeatedAnimation(this.player);
                }
                component.GenerateLocalHandCollision();
            }
            else
            {
                this.Push(animator.runtimeAnimatorController);
            }
        }
        else
        {
            this.Push(animator.runtimeAnimatorController);
        }
    }
Exemplo n.º 5
0
    // Token: 0x06005003 RID: 20483 RVA: 0x001B5544 File Offset: 0x001B3944
    public void Initialize(Animator animator, VRC_AvatarDescriptor Ad, bool local)
    {
        VRC_AnimationController component = base.GetComponent <VRC_AnimationController>();

        this.avatarManager            = base.transform.parent.GetComponentInChildren <VRCAvatarManager>();
        this.avatarAnimation          = base.GetComponent <AvatarAnimation>();
        this.player                   = base.transform.parent.GetComponent <VRC.Player>();
        this.mInitialized             = true;
        this.mAvatarAnimator          = animator;
        this.mAnimatorControllerStack = new List <RuntimeAnimatorController>();
        if (animator.isHuman)
        {
            this.Push(this.tPoseController);
            animator.updateMode  = AnimatorUpdateMode.UnscaledTime;
            animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
            animator.Update(0.01f);
            animator.transform.localPosition = Vector3.zero;
            animator.transform.localRotation = Quaternion.identity;
            if (component != null)
            {
                component.RecordTPose(animator);
            }
            this.avatarManager.MeasureHumanAvatar(animator);
            animator.updateMode = AnimatorUpdateMode.Normal;
            if (!local)
            {
                animator.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
            }
        }
        this.Finalize(animator, Ad, local);
    }
Exemplo n.º 6
0
        /// <summary>
        /// Gets camera offsets from viewpoint and returns a SerialTransform
        /// </summary>
        /// <returns>SerialTransform only holds values, it doesn't reference a real transform</returns>
        public static SerialTransform GetOffsetsFromViewpoint(VRC_AvatarDescriptor desc, Camera cam)
        {
            SerialTransform offsets = new SerialTransform();
            Transform       dummy   = null;

            try
            {
                dummy = new GameObject("Dummy").transform;
                dummy.localPosition = desc.ViewPosition + desc.gameObject.transform.position;

                offsets.localPosition    = cam.transform.localPosition - dummy.localPosition;
                offsets.localEulerAngles = cam.transform.localEulerAngles - dummy.localEulerAngles;
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
            finally
            {
                if (dummy)
                {
                    Helpers.DestroyAppropriate(dummy.gameObject);
                }
            }
            return(offsets);
        }
Exemplo n.º 7
0
    /// <summary>
    /// 設定処理
    /// </summary>
    /// <param name="tmpData">設定値情報</param>
    private void LipSyncAutoSelect(ITmpInterface tmpData = null)
    {
        VRC_AvatarDescriptor avatarDescriptor = GetVRCAvatarDescriptor();
        Dictionary <VRC_AvatarDescriptor.Viseme, string> matchData = tmpData == null ? null : tmpData.GetDataSet();

        if (avatarDescriptor.lipSync == VRC_AvatarDescriptor.LipSyncStyle.VisemeBlendShape)
        {
            List <string> blendShapeNames = GetBlendShapeNames();
            foreach (string name in Enum.GetNames(typeof(VRC_AvatarDescriptor.Viseme)))
            {
                if ("Count" == name)
                {
                    continue;
                }


                VRC_AvatarDescriptor.Viseme selectVisem = (VRC_AvatarDescriptor.Viseme)Enum.Parse(typeof(VRC_AvatarDescriptor.Viseme), name);
                if (matchData == null)
                {
                    string   pattern    = ".*[^A-Za-z]" + name.ToLower() + "$";
                    string[] matchNames = blendShapeNames.Where(t => t.ToLower() == name.ToLower() || Regex.IsMatch(t.ToLower(), pattern)).ToArray();
                    if (0 < matchNames.Length)
                    {
                        avatarDescriptor.VisemeBlendShapes[(int)selectVisem] = matchNames[0];
                    }
                }
                else
                {
                    avatarDescriptor.VisemeBlendShapes[(int)selectVisem] = matchData[selectVisem];
                }
            }
        }
    }
Exemplo n.º 8
0
 public VRCAvatar2(VRC_AvatarDescriptor descriptor) : this()
 {
     if (descriptor == null)
     {
         return;
     }
     LoadAvatarInfo(descriptor);
 }
Exemplo n.º 9
0
        protected ModuleBase(GestureManager manager, VRC_AvatarDescriptor avatarDescriptor)
        {
            Manager          = manager;
            AvatarDescriptor = avatarDescriptor;

            Avatar         = avatarDescriptor.gameObject;
            AvatarAnimator = Avatar.GetComponent <Animator>();
        }
Exemplo n.º 10
0
    /// <summary>
    /// アクティブの情報をコピー
    /// </summary>
    private void LipSyncCopy()
    {
        VRC_AvatarDescriptor avatarDescriptor = GetVRCAvatarDescriptor();

        if (avatarDescriptor.lipSync == VRC_AvatarDescriptor.LipSyncStyle.VisemeBlendShape)
        {
            copyVisemeBlendShapes = avatarDescriptor.VisemeBlendShapes;
        }
    }
Exemplo n.º 11
0
 // Token: 0x060058E6 RID: 22758 RVA: 0x001ECBC0 File Offset: 0x001EAFC0
 private void AvatarCreated(GameObject avatar, VRC_AvatarDescriptor Desc, bool loaded)
 {
     this.switcher = base.GetComponent <VRCAvatarManager>();
     if (this.switcher.profile != null)
     {
     }
     Tools.SetLayerRecursively(base.gameObject, base.transform.parent.gameObject.layer, -1);
     this.SetAvatarPose();
 }
Exemplo n.º 12
0
    // Token: 0x06005A83 RID: 23171 RVA: 0x001F860C File Offset: 0x001F6A0C
    private void SetAvatarPose(RuntimeAnimatorController rac)
    {
        Animator             componentInChildren  = base.GetComponentInChildren <Animator>();
        VRC_AvatarDescriptor componentInChildren2 = base.GetComponentInChildren <VRC_AvatarDescriptor>();

        if (rac != null)
        {
            componentInChildren.runtimeAnimatorController = rac;
        }
        else if (componentInChildren2 == null)
        {
            componentInChildren.runtimeAnimatorController = this.avatarSwitcher.animatorControllerMale;
        }
        else if (componentInChildren2.Animations == VRC_AvatarDescriptor.AnimationSet.Female)
        {
            componentInChildren.runtimeAnimatorController = this.avatarSwitcher.animatorControllerFemale;
        }
        else
        {
            componentInChildren.runtimeAnimatorController = this.avatarSwitcher.animatorControllerMale;
        }
        int layerIndex  = componentInChildren.GetLayerIndex("Idle Layer");
        int layerIndex2 = componentInChildren.GetLayerIndex("Locomotion Layer");
        int layerIndex3 = componentInChildren.GetLayerIndex("HandLeft");
        int layerIndex4 = componentInChildren.GetLayerIndex("HandRight");

        if (layerIndex >= 0)
        {
            componentInChildren.SetLayerWeight(layerIndex, 1f);
        }
        if (layerIndex2 >= 0)
        {
            componentInChildren.SetLayerWeight(layerIndex2, 0f);
        }
        if (layerIndex3 >= 0)
        {
            componentInChildren.SetLayerWeight(layerIndex3, 0f);
        }
        if (layerIndex4 >= 0)
        {
            componentInChildren.SetLayerWeight(layerIndex4, 0f);
        }
        componentInChildren.SetFloat("HeightScale", 1f);
        componentInChildren.SetFloat("HeightScaleNOMOVE", 1f);
        VRIK component = componentInChildren.GetComponent <VRIK>();

        if (component != null)
        {
            component.enabled = false;
        }
        global::LimbIK component2 = componentInChildren.GetComponent <global::LimbIK>();

        if (component2 != null)
        {
            component2.enabled = false;
        }
    }
Exemplo n.º 13
0
 public static GameObject getVRCSceneAvatar()
 {
     VRC_AvatarDescriptor[] vrcads = Object.FindObjectsOfType <VRC_AvatarDescriptor>();
     if (vrcads.Length > 0)
     {
         VRC_AvatarDescriptor vrcad  = vrcads[0];
         GameObject           avatar = vrcad.gameObject;
         return(avatar);
     }
     return(null);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Gets camera offset from viewpoint and returns a SerialTransform
        /// </summary>
        /// <returns>SerialTransform only holds values, it doesn't reference a real transform</returns>
        public static SerialTransform GetCameraOffsetFromViewpoint(GameObject avatar, Camera cam)
        {
            VRC_AvatarDescriptor desc    = avatar.GetComponent <VRC_AvatarDescriptor>();
            SerialTransform      offsets = null;

            if (desc)
            {
                offsets = GetOffsetsFromViewpoint(desc, cam);
            }
            return(offsets);
        }
    /// <summary>
    /// アバターの情報を取得する
    /// </summary>
    private void GetAvatarInfo(VRC_AvatarDescriptor avatar)
    {
        if (avatar == null)
        {
            return;
        }

        targetObject = avatar.gameObject;

        standingAnimController = avatar.CustomStandingAnims;
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        ViewpointSetter script = (ViewpointSetter)target;

        if (GUILayout.Button("set viewpoint"))
        {
            VRC_AvatarDescriptor vrcad = GestureDisplay.getVRCSceneAvatar().GetComponent <VRC_AvatarDescriptor>();
            vrcad.ViewPosition = script.transform.position;
            DestroyImmediate(script.gameObject);
        }
    }
Exemplo n.º 17
0
    // Token: 0x060053F6 RID: 21494 RVA: 0x001CFC08 File Offset: 0x001CE008
    public void SetProperties(List <VRCPlayerModProperty> properties)
    {
        Dictionary <string, object> dictionary = new Dictionary <string, object>();

        foreach (VRCPlayerModProperty vrcplayerModProperty in properties)
        {
            dictionary[vrcplayerModProperty.name] = vrcplayerModProperty.value();
        }
        this.propPrefab     = (GameObject)Tools.GetOrDefaultFromDictionary(dictionary, "PropPrefab", null);
        this.propAnimations = (RuntimeAnimatorController)Tools.GetOrDefaultFromDictionary(dictionary, "PropAnimations", null);
        VRC_AvatarDescriptor componentInChildren = base.GetComponentInChildren <VRC_AvatarDescriptor>();

        if (componentInChildren == null)
        {
            return;
        }
        this._avatar = componentInChildren.gameObject;
        Animator component = this._avatar.GetComponent <Animator>();

        if (component.isHuman)
        {
            if (this._animator == null)
            {
                this._animator = component;
                if (this.propAnimations != null)
                {
                    this._animControllerManager.Push(this.propAnimations);
                }
            }
            else if (this._animator != component)
            {
                this._animator = component;
            }
            if (this.propPrefab != null)
            {
                this.propInstance = (GameObject)AssetManagement.Instantiate(this.propPrefab);
                this.propApi      = this.propInstance.GetComponent <VRC_PropApi>();
                this.propControls = this.propInstance.GetComponent <VRC_PropController>();
                if (this.propControls != null)
                {
                    this.propControls.controllingPlayer = base.GetComponent <VRC_PlayerApi>();
                }
                HumanBodyBones humanBodyBones = this.propApi.mountPoint;
                this.mountPoint = this._animator.GetBoneTransform(humanBodyBones);
                Quaternion tposeRotation = this._animationController.GetTPoseRotation(humanBodyBones);
                Quaternion localRotation = Quaternion.Inverse(tposeRotation) * this.propInstance.transform.rotation;
                this.propInstance.transform.parent        = this.mountPoint;
                this.propInstance.transform.localPosition = Vector3.zero;
                this.propInstance.transform.localRotation = localRotation;
            }
        }
    }
Exemplo n.º 18
0
    void InitForAvatar(VRCSDK2.VRC_AvatarDescriptor descriptor)
    {
        avatar           = descriptor.gameObject;
        avatarDescriptor = descriptor;

        avatarAnimator = avatar.GetComponent <Animator>();
        if (avatarAnimator == null)
        {
            avatarAnimator = avatar.AddComponent <Animator>();
        }

        SetupOverride(ControllerType.STANDING);
    }
Exemplo n.º 19
0
    // Token: 0x06004E8C RID: 20108 RVA: 0x001A5644 File Offset: 0x001A3A44
    public void Initialize(VRC_AvatarDescriptor descriptor, Animator animator, bool Local)
    {
        if (!Local)
        {
            return;
        }
        this.CameraMount = base.transform.Find("../CameraMount");
        Vector3 viewPosition = descriptor.ViewPosition;

        viewPosition.z = 0f;
        this.CameraMount.localPosition = viewPosition;
        this.BaseHeadPos = this.CameraMount.localPosition;
        this.Initialized = true;
    }
Exemplo n.º 20
0
        public static ModuleBase GetModuleForDescriptor(GestureManager manager, VRC_AvatarDescriptor descriptor)
        {
            switch (descriptor)
            {
#if VRC_SDK_VRCSDK2
            case VRCSDK2.VRC_AvatarDescriptor descriptorV2:
                return(new Vrc2.ModuleVrc2(manager, descriptorV2));
#endif
#if VRC_SDK_VRCSDK3
            case VRC.SDK3.Avatars.Components.VRCAvatarDescriptor descriptorV3:
                return(new Vrc3.ModuleVrc3(manager, descriptorV3));
#endif
            default: return(null);
            }
        }
Exemplo n.º 21
0
    // Token: 0x06005781 RID: 22401 RVA: 0x001E2EBC File Offset: 0x001E12BC
    private void LoadAvatarFromAssetBundle(string url, UnityEngine.Object asset)
    {
        GameObject           gameObject = asset as GameObject;
        VRC_AvatarDescriptor component  = gameObject.GetComponent <VRC_AvatarDescriptor>();

        if (component != null)
        {
            this.LoadAvatarFromAsset(url, asset, this.currentScale);
        }
        else
        {
            this.SwitchToErrorAvatar(1f);
            Debug.LogWarning("Attempting to load a non-custom-avatar asset into an avatar asset. www.assetBundle.mainAsset.name = " + asset.name + " from url " + url);
        }
    }
Exemplo n.º 22
0
        /// <summary>
        /// Returns position and rotation offsets from viewpoint to camera
        /// </summary>
        public void CalculateOffsets(VRC_AvatarDescriptor desc, Camera cam)
        {
            if (!desc || !cam)
            {
                return;
            }

            SerialTransform offsets = GetOffsetsFromViewpoint(desc, cam);

            if (offsets)
            {
                offsetMode           = CameraOffsetMode.Viewpoint;
                positionOffset       = offsets.localPosition;
                rotationAnglesOffset = offsets.localEulerAngles;
            }
        }
Exemplo n.º 23
0
    // Token: 0x060058DC RID: 22748 RVA: 0x001EC7A0 File Offset: 0x001EABA0
    private void AvatarCreated(GameObject avatar, VRC_AvatarDescriptor Desc, bool loaded)
    {
        this.switcher = base.GetComponent <VRCAvatarManager>();
        if (this.switcher.profile != null)
        {
        }
        VRC_KeyEvents[] componentsInChildren = avatar.GetComponentsInChildren <VRC_KeyEvents>();
        foreach (VRC_KeyEvents vrc_KeyEvents in componentsInChildren)
        {
            vrc_KeyEvents.enabled = false;
        }
        Tools.SetLayerRecursively(base.gameObject, base.transform.parent.gameObject.layer, -1);
        Animator component = this.switcher.currentAvatar.GetComponent <Animator>();

        this.vrikCalib.Initialize(component, this.switcher.currentAvatarDescriptor.ViewPosition.y);
    }
Exemplo n.º 24
0
 // Token: 0x06005A82 RID: 23170 RVA: 0x001F8584 File Offset: 0x001F6984
 private void AvatarIsReady(GameObject avatar, VRC_AvatarDescriptor Ad, bool loaded)
 {
     this.avatarAnimator = avatar.GetComponent <Animator>();
     if (this.avatarAnimator != null)
     {
         this.animationController.Reset(this.avatarAnimator, Ad);
         this.animControlManager.Initialize(this.avatarAnimator, Ad, false);
         this.SetupHead();
         this.lastPosition = base.transform.position;
         this.locoWeight   = 0f;
     }
     if (this.onAvatarIsReady != null)
     {
         this.onAvatarIsReady();
     }
 }
Exemplo n.º 25
0
    // Token: 0x060053DA RID: 21466 RVA: 0x001CEC44 File Offset: 0x001CD044
    public void SetProperties(List <VRCPlayerModProperty> properties)
    {
        Dictionary <string, object> dictionary = new Dictionary <string, object>();

        foreach (VRCPlayerModProperty vrcplayerModProperty in properties)
        {
            dictionary[vrcplayerModProperty.name] = vrcplayerModProperty.value();
        }
        this.gunPrefab     = (GameObject)Tools.GetOrDefaultFromDictionary(dictionary, "GunPrefab", null);
        this.gunAnimations = (RuntimeAnimatorController)Tools.GetOrDefaultFromDictionary(dictionary, "GunAnimations", null);
        VRC_AvatarDescriptor componentInChildren = base.GetComponentInChildren <VRC_AvatarDescriptor>();

        if (componentInChildren == null)
        {
            return;
        }
        this._avatar = componentInChildren.gameObject;
        Animator component = this._avatar.GetComponent <Animator>();

        if (component.isHuman)
        {
            if (this._animator == null)
            {
                this._animator = component;
                if (this.gunAnimations != null)
                {
                    this._animControllerManager.Push(this.gunAnimations);
                }
            }
            else if (this._animator != component)
            {
                this._animator = component;
            }
            this.rightHand = this._animator.GetBoneTransform(HumanBodyBones.RightHand);
            if (this.gunPrefab != null && this.rightHand != null)
            {
                this.gunInstance = (GameObject)AssetManagement.Instantiate(this.gunPrefab);
                this.gunStats    = this.gunInstance.GetComponent <VRC_GunStats>();
                this.gunControls = this.gunInstance.GetComponent <VRC_PropController>();
                this.gunControls.controllingPlayer = base.GetComponent <VRC_PlayerApi>();
                this.ClipContents = ((this.gunStats.clipSize == 0) ? -1 : this.gunStats.clipSize);
                this.gunInstance.transform.parent        = this.rightHand;
                this.gunInstance.transform.localPosition = Vector3.zero;
                this.gunInstance.transform.localRotation = Quaternion.Inverse(this._animationController.GetTPoseRotation(HumanBodyBones.RightHand)) * this.gunInstance.transform.rotation;
            }
        }
    }
Exemplo n.º 26
0
        private static void OnLocalPlayerAvatarCreatedImpl(GameObject go, VRC_AvatarDescriptor descriptor)
        {
            if (!ourIsEnabled.Value)
            {
                return;
            }

            if (descriptor == null || descriptor.TryCast <VRCSDK2.VRC_AvatarDescriptor>() != null)
            {
                MelonLogger.Msg("Current avatar is SDK2, ignoring rescaling support");
                return;
            }

            var originalScale = go.transform.localScale;

            MelonCoroutines.Start(OnLocalPlayerAvatarCreatedCoro(originalScale, go));
        }
Exemplo n.º 27
0
    /// <summary>
    /// コピー情報の内容を設定
    /// </summary>
    private void LipSyncPaste()
    {
        VRC_AvatarDescriptor avatarDescriptor = GetVRCAvatarDescriptor();

        if (avatarDescriptor.lipSync == VRC_AvatarDescriptor.LipSyncStyle.VisemeBlendShape && copyVisemeBlendShapes != null)
        {
            List <string> blendShapeNames = GetBlendShapeNames();
            for (int i = 0; i < copyVisemeBlendShapes.Length; i++)
            {
                string[] matchNames = blendShapeNames.Where(t => t == copyVisemeBlendShapes[i]).ToArray();
                if (0 < matchNames.Length)
                {
                    avatarDescriptor.VisemeBlendShapes[i] = matchNames[0];
                }
            }
        }
    }
Exemplo n.º 28
0
    void OnEnable()
    {
#if UNITY_EDITOR
        Reset();

        if (GetComponents <BhapticsVRCEditor>().Length > 1)
        {
            Debug.LogError("BhapticsVRCEditor / Only one component can be added");
            DestroyImmediate(this);
            return;
        }

        anim = GetComponent <Animator>();
        if (anim == null)
        {
            Debug.LogError("BhapticsVRCEditor / Required Animator component & avatar.");
            return;
        }

        if (anim.avatar == null)
        {
            Debug.LogError("BhapticsVRCEditor / Required Animator component & avatar.");
            return;
        }

        avatarDescriptor = GetComponent <VRC_AvatarDescriptor>();
        if (avatarDescriptor == null)
        {
            Debug.LogError("BhapticsVRCEditor / Required VRC AvatarDescriptor component.");
            return;
        }

        for (int i = 0; i < deviceIcons.Length; ++i)
        {
            var path = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets(deviceIconFileNames[i], null)[0]);
            deviceIcons[i] = AssetDatabase.LoadAssetAtPath <Texture>(path);
        }
        for (int i = 0; i < deviceOnIcons.Length; ++i)
        {
            var path = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets(deviceOnIconFileNames[i], null)[0]);
            deviceOnIcons[i] = AssetDatabase.LoadAssetAtPath <Texture>(path);
        }

        SetupOffsets();
#endif
    }
Exemplo n.º 29
0
 private static void OnAvatarInstantiated(IntPtr @this, IntPtr avatarPtr, IntPtr avatarDescriptorPtr,
                                          bool loaded)
 {
     _onAvatarInstantiatedDelegate(@this, avatarPtr, avatarDescriptorPtr, true);
     try
     {
         var avatarDescriptor = new VRC_AvatarDescriptor(avatarDescriptorPtr);
         if (VRCPlayer.field_Internal_Static_VRCPlayer_0?.prop_VRCAvatarManager_0
             ?.prop_VRCAvatarDescriptor_0 !=
             null && avatarDescriptor == VRCPlayer.field_Internal_Static_VRCPlayer_0.prop_VRCAvatarManager_0
             .prop_VRCAvatarDescriptor_0)
         {
             MainMod.EyeTrackParams = MainMod.EmptyList();
         }
     }
     catch (Exception e)
     {
         MelonLogger.Error(e.ToString());
     }
 }
Exemplo n.º 30
0
 private static void UploadAvatarResource()
 {
     //IL_004f: Unknown result type (might be due to invalid IL or missing references)
     //IL_0068: Unknown result type (might be due to invalid IL or missing references)
     if (!string.IsNullOrEmpty(vrcPath))
     {
         int num = 0;
         if (!string.IsNullOrEmpty(vrcPath) && ValidationHelpers.CheckIfAssetBundleFileTooLarge(2, vrcPath, ref num))
         {
             EditorUtility.DisplayDialog("Could not publish avatar", ValidationHelpers.GetAssetBundleOverSizeLimitMessage(2, num), "Ok");
         }
         else
         {
             VRC_AvatarDescriptor component = Selection.get_activeObject().GetComponent <VRC_AvatarDescriptor>();
             PipelineSaver        val       = component.get_gameObject().AddComponent <PipelineSaver>();
             val.contentType = 0;
             EditorApplication.set_isPlaying(true);
             VRCPipelineManagerEditor.launchedFromSDKPipeline = true;
         }
     }
 }