• <em id="6vhwh"><rt id="6vhwh"></rt></em>

    <style id="6vhwh"></style>

    <style id="6vhwh"></style>
    1. <style id="6vhwh"></style>
        <sub id="6vhwh"><p id="6vhwh"></p></sub>
        <p id="6vhwh"></p>
          1. 国产亚洲欧洲av综合一区二区三区 ,色爱综合另类图片av,亚洲av免费成人在线,久久热在线视频精品视频,成在人线av无码免费,国产精品一区二区久久毛片,亚洲精品成人片在线观看精品字幕 ,久久亚洲精品成人av秋霞

            Unity3d官方角色換裝Demo源代碼學(xué)習(xí)

            更新時(shí)間:2025-12-10 06:07:53 閱讀: 評(píng)論:0

            2023年12月11日發(fā)(作者:什么樣的目光)

            Unity3d官方角色換裝Demo源代碼學(xué)習(xí)

            由于興趣愛好,工作之余會(huì)嘗試做做RPG游戲,遇到角色換裝這個(gè)功能沒什么思路,于是在網(wǎng)上苦苦找尋相關(guān)資料,網(wǎng)上角色換裝文章

            還是有一些,不過大多講的比較簡(jiǎn)單,最后沒辦法不得不拿官方的角色換裝代碼來研究,開始看到一頭霧水,不過慢慢找到看這個(gè)Demo代

            碼的思路,終于理清了換裝的思路。

            其實(shí),可以從角色換裝資源打包代碼看起,然后看換裝代碼。

            以下是我看代碼的思路: ->

            換裝的核心代碼如下:

            (1)打包代碼

            using c;

            using ;

            using UnityEditor;

            using UnityEngine;

            class CreateAstbundles

            {

            // This method creates an astbundle of each SkinnedMeshRenderer

            // found in any lected character fbx, and adds any materials that

            // are intended to be ud by the specific SkinnedMeshRenderer.

            [MenuItem("Character Generator/Create Astbundles")]

            static void Execute()

            {

            bool createdBundle = fal;

            foreach (Object o in tered(typeof (Object), ts))

            {

            if (!(o is GameObject)) continue;

            if (ns("@")) continue;

            if (!etPath(o).Contains("/characters/")) continue;

            GameObject characterFBX = (GameObject)o;

            string name = r();

            ("******* Creating astbundles for: " + name + " *******");

            // Create a directory to store the generated astbundles.

            if (!(AstbundlePath))

            Directory(AstbundlePath);

            // Delete existing astbundles for current character.

            string[] existingAstbundles = es(AstbundlePath);

            foreach (string bundle in existingAstbundles)

            {

            if (th(".astbundle") && ns("/astbundles/" + name))

            (bundle);

            }

            // Save bones and animations to a perate astbundle. Any

            // possible combination of CharacterElements will u the

            // asts as a ba. As we can not edit asts we instantiate

            // the fbx and remove what we dont need. As only asts can be

            // added to astbundles we save the result as a prefab and delete

            // it as soon as the astbundle is created.

            GameObject characterClone = (GameObject)tiate(characterFBX);

            // postprocess animations: we need them animating even offscreen

            foreach (Animation anim in ponentsInChildren())

            eOnlyIfVisible = fal; foreach (SkinnedMeshRenderer smr in ponentsInChildren()) yImmediate(ject);

            ponent(); Object characterBaPrefab = GetPrefab(characterClone, "characterba"); string path = AstbundlePath + name + "_undle"; stBundle(characterBaPrefab, null, path, tDependencies); Ast(etPath(characterBaPrefab)); // Collect materials. List materials = tAll(alsPath(characterFBX)); // Create astbundles for each SkinnedMeshRenderer. foreach (SkinnedMeshRenderer smr in ponentsInChildren(true)) { List toinclude = new List(); // Save the current SkinnedMeshRenderer as a prefab so it can be included // in the astbundle. As instantiating part of an fbx results in the // entire fbx being instantiated, we have to dispo of the entire instance // after we detach the SkinnedMeshRenderer in question. GameObject rendererClone = (GameObject)tiatePrefab(ject); GameObject rendererParent = ject; = null; yImmediate(rendererParent); Object rendererPrefab = GetPrefab(rendererClone, "rendererobject"); (rendererPrefab); // Collect applicable materials. foreach (Material m in materials) if (ns(r())) (m); // When asmbling a character, we load SkinnedMeshRenderers from astbundles, // and as such they have lost the references to their bones. To be able to // remap the SkinnedMeshRenderers to u the bones from the characterba astbundles, // we save the names of the bones ud. List boneNames = new List(); foreach (Transform t in ) (); string stringholderpath = "Asts/";

            StringHolder holder = Instance (); t = y(); Ast(holder, stringholderpath); (tAtPath(stringholderpath, typeof (StringHolder))); // Save the astbundle. string bundleName = name + "_" + r(); path = AstbundlePath + bundleName + ".astbundle"; stBundle(null, y(), path, tDependencies); ("Saved " + bundleName + " with " + ( - 2) + " materials"); // Delete temp asts. Ast(etPath(rendererPrefab)); Ast(stringholderpath); createdBundle = true; } } if (createdBundle) e(); el } yDialog("Character Generator", "No Ast Bundles created. Select the characters folder in the Project pane to process all characters. Se

            static Object GetPrefab(GameObject go, string name)

            {

            Object tempPrefab = EmptyPrefab("Asts/" + name + ".prefab");

            tempPrefab = ePrefab(go, tempPrefab);

            yImmediate(go);

            return tempPrefab;

            }

            public static string AstbundlePath

            {

            get { return "astbundles" + orySeparatorChar; }

            }

            }

            (2)角色換裝代碼 // Creates a character bad on the currentConfiguration recycling a // character ba, this way the position and animation of the character // are not changed. public GameObject Generate(GameObject root) { float startTime = meSinceStartup; // The SkinnedMeshRenderers that will make up a character will be // combined into one SkinnedMeshRenderers using multiple materials. // This will speed up rendering the resulting character. List combineInstances = new List(); List materials = new List(); List bones = new List(); Transform[] transforms = ponentsInChildren();

            foreach (CharacterElement element in ) { SkinnedMeshRenderer smr = nnedMeshRenderer(); ge(als); for (int sub = 0; sub < hCount; sub++) { CombineInstance ci = new CombineInstance(); = Mesh; hIndex = sub; (ci); } // As the SkinnedMeshRenders are stored in astbundles that do not // contain their bones (tho are stored in the characterba astbundles) // we need to collect references to the bones we are using foreach (string bone in eNames()) { foreach (Transform transform in transforms) { if ( != bone) continue; (transform); break; } } y(ject); } // Obtain and configure the SkinnedMeshRenderer attached to // the character ba. SkinnedMeshRenderer r = ponent(); Mesh = new Mesh(); eMeshes(y(), fal, fal); = y(); als = y();

            ("Generating character took: " + (meSinceStartup - startTime) * 1000 + " ms"); return root; }

            本文發(fā)布于:2023-12-11 19:14:07,感謝您對(duì)本站的認(rèn)可!

            本文鏈接:http://www.newhan.cn/zhishi/a/88/41124.html

            版權(quán)聲明:本站內(nèi)容均來自互聯(lián)網(wǎng),僅供演示用,請(qǐng)勿用于商業(yè)和其他非法用途。如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除。

            本文word下載地址:Unity3d官方角色換裝Demo源代碼學(xué)習(xí).doc

            本文 PDF 下載地址:Unity3d官方角色換裝Demo源代碼學(xué)習(xí).pdf

            標(biāo)簽:換裝   角色   代碼   官方   源代碼
            留言與評(píng)論(共有 0 條評(píng)論)
               
            驗(yàn)證碼:
            推薦文章
            排行榜
            Copyright ?2019-2022 Comsenz Inc.Powered by ? 實(shí)用文體寫作網(wǎng)旗下知識(shí)大全大全欄目是一個(gè)全百科類寶庫(kù)! 優(yōu)秀范文|法律文書|專利查詢|
            • 我要關(guān)燈
              我要開燈
            • 返回頂部
            主站蜘蛛池模板: 亚洲av无码一区东京热| 在线永久看片免费的视频| 日韩精品久久不卡中文字幕| 伊人久久综合无码成人网| 国产啪在线91| 老师扒下内裤让我爽了一夜| 蜜桃亚洲一区二区三区四| 麻豆蜜桃伦理一区二区三区| 色二av手机版在线| 日韩中文字幕高清有码| 久久精品无码免费不卡| 亚洲AV无码久久精品成人| 国产精品免费AⅤ片在线观看| AV成人午夜无码一区二区| 亚洲不卡av不卡一区二区| 中文字幕在线无码一区二区三区 | 亚洲欧美偷国产日韩| 日韩中文无码av超清| 在线一区二区中文字幕| 狠狠躁天天躁中文字幕| 精品国产乱一区二区三区| 女人被爽到高潮视频免费国产| 涩欲国产一区二区三区四区| 国产综合久久99久久| a级毛片在线免费观看| 国产精品午夜av福利| 欧美国产视频| 国产精品系列在线免费看| 少妇和邻居做不戴套视频| 蜜臀av一区二区三区日韩| 色噜噜狠狠成人综合| 国产成人啪精品午夜网站| 国产精品久久久久乳精品爆 | 日本午夜精品一区二区三区电影| 国产精品自拍视频入口| 福利一区二区在线播放| 精品系列无码一区二区三区| 国产亚洲精品一区二区不卡 | 在线综合亚洲欧洲综合网站| 精品国产色情一区二区三区| 亚洲熟妇自偷自拍另欧美|