CodeMonkey技巧

本文探讨如何优化CodeMonkey的编程体验,主要介绍两种方法:一是利用全局资源,通过预设和单例模式高效管理资源,确保在需要时能快速调用;二是应用静态工厂,方便快捷地添加和管理脚本,提高开发效率。
摘要由CSDN通过智能技术生成

全局资源

  • 资源引用存为预设
  • 使用单例模式,在创建实例时加载预设
  • 使用资源时,只需要调用该单例
/* 
    ------------------- Code Monkey -------------------

    Thank you for downloading the Code Monkey Utilities
    I hope you find them useful in your projects
    If you have any questions use the contact form
    Cheers!

               unitycodemonkey.com
    --------------------------------------------------
 */

using UnityEngine;

namespace CodeMonkey
{
   
    /*
     * Global Asset references
     * Edit Asset references in the prefab CodeMonkey/Resources/CodeMonkeyAssets
     * */
    public class Assets : MonoBehaviour
    {
   
        // Internal instance reference
        private static Assets _i;

        // Instance reference
        public static Assets i
        {
   
            get
            {
   
                if (_i == null) _i = Instantiate(Resources.Load<Assets>(
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值