unity(Exploder外掛程式)研究

來源:互聯網
上載者:User

標籤:ram   color   --   class   pre   let   util   collect   速度   

哎 好久沒寫部落格了 不是因為最近忙 而是比較懶 學的東西不深入

前段時間發現一個很好用的外掛程式叫Exploder(是一個可以製作任何物體的爆炸效果)

好!我們開始我們的炸學校旅程!(O(∩_∩)O哈哈~ 開玩笑了)

不過這次我們使用的模型就是一個學校模型

首先:我們在學校中安裝一個炸彈 --將外掛程式中的Exploder預製體拖進去

選中要爆炸的物體 tag層設定為Exploder

開始擼代碼~~~

 

using System.Collections;using System.Collections.Generic;using UnityEngine;namespace Exploder.Utils {  //調用這個命名空間    public class ExploderThings : MonoBehaviour {        private ExploderObject Exploder;        void Start() {            Exploder = Utils.ExploderSingleton.ExploderInstance;                    }        private void OnGUI()        {            if (GUI.Button(new Rect(0, 0, 100, 100), "爆炸"))            {                ExplodeObject(gameObject);            }        }        // Update is called once per frame        void Update() {        }        void ExplodeObject(GameObject gameObject)        {            ExploderUtils.SetActive(Exploder.gameObject, true);            Exploder.transform.position = ExploderUtils.GetCentroid(gameObject);            Exploder.Radius = 1f;            Exploder.ExplodeRadius();        }    }}

附在物體上運行後:

完成物體的爆炸!

當然源碼裡面還有很多的功能:

IsExplodable(GameObject obj) //判斷obj物體是否可被爆炸

Exploder.ExplodeObject(GameObject obj,OnExplosion callback)
callback 一般用來爆炸後的處理函數 比如聲音播放 粒子的播放

ExplodeRadius() //在一個範圍內搜尋爆炸物

Exploder.transform.position = ExploderUtils.GetCentroid(gameObject); //爆炸範圍移動到當前物體上
Exploder.Radius = 1.0f; //爆炸的半徑

 

當然不會用代碼控制的小白們 外掛程式在面板上也整合了幾個可調參數:

Explodable fragments 表示片段是否可以迭代的再次破損

PoolSize 情境中最多產生的片段數  運行後面板上會多出一個(FragmentRoot)那裡就是存放的片段

Fragment prefab 自己可以定義片段的預製體

layer  片段的層 (int型數字)

MaxVelocity 片段最大的炸裂速度

等等 自行根據Tooltip提示猜

unity(Exploder外掛程式)研究

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.