unity发布WebGL遇到的坑(持续更新)

1、unity默认字体在网页中不会显示

解决方法:自己新导入一个字体,使用导入的字体

2、之前打过包并运行过,后面又在unity中进行了修改,重新打包,运行发现还是修改之前的效果,虽然是新包,

解决方法:这是因为网页中有缓存, 点击浏览器右边的三个点,选择设置--隐私、搜索与服务--清除浏览数据,清除后重新运行

3、如果unity 里使用了ILRintime热更新,和DoTween插件,在热更里使用了DoTween,运行WebGL时运行到Do处代码会报错。

Cannot find Type:DG.Tweening.ShortcutExtensions

at ILRuntime.Runtime.Enviorment.AppDomain.GetType (System.Object token, ILRuntime.CLR.TypeSystem.IType contextType, ILRuntime.CLR.Method.IMethod contextMethod) [0x00000] in <00000000000000000000000000000000>:0

解决方法:在unity里把Do的功能重新封装一下,然后在热更里掉用封装好的类

csharp 复制代码
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DoTweenTool 
{
    private static DoTweenTool _instance;
    public static DoTweenTool Instance
    {
        get
        {
            if (_instance == null)
            {
                _instance = new DoTweenTool();
            }
            return _instance;
        }
    }
    Dictionary<string, Tween> tweenDic = new Dictionary<string, Tween>();

    public void DoColor( Image target,Color endValue,float duration)
    {
        Tween tween= target.DOColor( endValue, duration);
        if(!tweenDic.ContainsKey(target.name))
        {
            tweenDic.TryAdd(target.name, tween);

        }
    }

    public void DOAnchorPosX(RectTransform target,float endValue,float duration)
    {
        Tween tween= target.DOAnchorPosX(endValue, duration);
        if (!tweenDic.ContainsKey(target.name))
        {
            tweenDic.TryAdd(target.name, tween);

        }
    }

    public void DOText(Text target,string content,float duration,Action action)
    {
        Tween tween=  target.DOText(content, duration).SetEase(Ease.Linear).OnUpdate(()=> { action?.Invoke(); });
        if (!tweenDic.ContainsKey(target.name))
        {
            tweenDic.TryAdd(target.name, tween);

        }
    }

    public void DOLocalMoveX(Transform target,float endValue,float duration)
    {
        Tween tween = target.DOLocalMoveX(endValue, duration);
        if (!tweenDic.ContainsKey(target.name))
        {
            tweenDic.TryAdd(target.name, tween);

        }
    }

    public void Kill(string name)
    {
        if (tweenDic.ContainsKey(name))
        {
            tweenDic.Remove(name);

        }
    }
}
相关推荐
霜绛1 小时前
Unity:GUI笔记(一)——文本、按钮、多选框和单选框、输入框和拖动条、图片绘制和框绘制
笔记·学习·unity·游戏引擎
谷宇.3 小时前
【Unity3D实例-功能-移动】角色行走和奔跑的相互切换
游戏·unity·c#·unity3d·游戏开发·游戏编程
17岁的勇气4 小时前
Unity Shader unity文档学习笔记(十九):粘土效果,任意网格转化成一个球(顶点动画,曲面着色器)
笔记·学习·unity·图形渲染·顶点着色器·曲面着色器
烛阴14 小时前
Clamp
前端·webgl
benben04419 小时前
《Unity Shader入门精要》学习笔记一
unity·shader
YF云飞19 小时前
Unity图片优化与比例控制全攻略
游戏·unity·游戏引擎·游戏程序·个人开发
答案answer20 小时前
three.js 实现几个好看的文本内容效果
前端·webgl·three.js
SmalBox21 小时前
【渲染流水线】[几何阶段]-[几何着色]以UnityURP为例
unity·渲染
sixgod_h1 天前
Threejs源码系列- Quaternion
webgl·three.js
sixgod_h1 天前
Threejs源码系列- MathUtils(2)
前端·webgl