分类 Unity 下的文章

直接从官网下载的deb安装后会出现问题,比如,hub界面打不开、无法创建证书,无法激活等问题

下载 OpenSSL 1.0

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.10_amd64.deb

安装

sudo dpkg -i libssl1.0.0_1.0.2n-1ubuntu5.10_amd64.deb

添加 Unity3D 存储库

sudo sh -c 'echo "deb https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list'

添加公共签名密钥

wget -qO - https://hub.unity3d.com/linux/keys/public | sudo tee /etc/apt/trusted.gpg.d/unityhub.asc

安装 Unity Hub

sudo apt update
sudo apt install unityhub

卸载 Unity Hub

sudo apt remove unityhub

sendpix1.jpg
sendpix2.jpg

原文地址
https://dev.to/brenomfviana/installing-unity-hub-on-ubuntu-42l0

使用的是GLTFUtility https://github.com/Siccity/GLTFUtility.git
gltf样品库 https://github.com/KhronosGroup/glTF-Sample-Models.git
我的测试模型 https://www.xuefei.net.cn/unitywebgl/WaterBottle.glb
我的webgl测试地址 https://www.xuefei.net.cn/unitywebgl/index.html
主要代码

using System.Collections;
using UnityEngine;
using Siccity.GLTFUtility;
using UnityEngine.UI;
using UnityEngine.Networking;

public class GLTFTest : MonoBehaviour
{
    public Button button;
    public GameObject loadGo = null;

    // Start is called before the first frame update
    void Start()
    {
        button.onClick.AddListener(delegate
        {
            StartCoroutine(LoadGo());
        });
    }

    private IEnumerator LoadGo()
    {
        if (loadGo != null)
        {
            DestroyImmediate(loadGo);
            Resources.UnloadUnusedAssets();
        }
        var request = UnityWebRequest.Get("https://www.xuefei.net.cn/unitywebgl/WaterBottle.glb");
        yield return request.SendWebRequest();
        if (request.result != UnityWebRequest.Result.Success)
        {
            Debug.LogError(request.error);
        }
        else
        {
            Debug.Log(request.downloadHandler.text);
            loadGo = Importer.LoadFromBytes(request.downloadHandler.data);
        }
    }
}

效果图
20220731132356.png

https://github.com/homuler/MediaPipeUnityPlugin

You cannot build libraries for Android with the following steps.

1、安装msys2配置系统环境变量Path添加 C:\msys64\usr\bin
执行 pacman -Su
执行 pacman -S git patch unzip
2、安装Python3.9.10 勾选系统环境变量 执行pip install numpy --user
3、安装VS2019,勾选使用C++的桌面开发
4、下载bazel-5.0.0-windows-x86_64.exe 重命名为bazel.exe 并配置系统环境变量
设置Bazel变量
set BAZEL_VS=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC
set BAZEL_VC_FULL_VERSION=14.29.30133
set BAZEL_WINSDK_FULL_VERSION=10.0.19041.0
5、下载nuget 并配置系统环境变量
6、下载opencv-3.4.16-vc14_vc15.exe 运行解压在C盘根目录
7、Android Build Tools<31 Android NDT <22 配置系统环境变量sdk ANDROID_HOME ndk ANDROID_NDK_HOME
步骤7不需要,该工程无法创建Android libraries

最后MediaPipeUnityPlugin工程目录下执行 python build.py build --desktop cpu --opencv=cmake -v
编译
Unity编辑器运行

.\ffmpeg -i .\test.mov -vcodec libvpx -auto-alt-ref 0 -acodec libvorbis test.webm
vcodec libvpx 是视频vp8 -acodec libvorbis是音频vorbis
unity不支持vp9

截取视频前3秒
.\ffmpeg -i test.webm -vcodec copy -acodec copy -ss 00:00:00 -to 00:00:03 testnew.webm

using System;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class UScrollRect : ScrollRect
{
    public RectTransform rect;
    /// <summary>
    /// 高度 往下拉是负数   往上拉是正数
    /// </summary>
    float dropValue = -30f;
    /// <summary>
    /// 是否刷新
    /// </summary>
    bool isRefresh = false;
    /// <summary>
    /// 是否处于拖动
    /// </summary>
    bool isDrag = false;
    /// <summary>
    /// 显示、隐藏刷新字段
    /// </summary>
    public Action<bool> OnValue;
    /// <summary>
    /// 如果满足刷新条件 执行的方法
    /// </summary>
    public Action OnRefresh;

    protected override void Awake()
    {
        base.Awake();
        rect = GetComponentInChildren<ContentSizeFitter>().GetComponent<RectTransform>();
        onValueChanged.AddListener(ScrollValueChanged);
    }

    /// <summary>
    /// 当ScrollRect被拖动时
    /// </summary>
    /// <param name="vector">被拖动的距离与Content的大小比例</param>
    void ScrollValueChanged(Vector2 vector)
    {
        //如果不拖动 当然不执行之下的代码
        if (!isDrag)
        {
            return;
        }
        //如果拖动的距离大于给定的值
        if (rect.anchoredPosition.y < dropValue)
        {
            isRefresh = true;
            if (OnValue != null)
            {
                OnValue(isRefresh);
            }
        }
        else
        {
            isRefresh = false;
            if (OnValue != null)
            {
                OnValue(isRefresh);
            }
        }
    }

    public override void OnBeginDrag(PointerEventData eventData)
    {
        base.OnBeginDrag(eventData);
        isDrag = true;
    }

    public override void OnEndDrag(PointerEventData eventData)
    {
        base.OnEndDrag(eventData);
        OnValue(false);
        if (isRefresh)
        {
            if (OnRefresh != null)
            {
                OnRefresh();
            }
        }
        isRefresh = false;
        isDrag = false;
    }
}