Unity中遇到的问题

一、协程调用

  1. 不继承MonoBehaviour 的类才可以调用协程的方法:写一个类继承Monobehaviour

//********************************************************************
// 文件名: CoroutineController 
// 描述: 继承MonoBehaviour 的单利
// 作者: 鞠明明
// 创建时间: 4/20/2017 8:20:23 PM
//********************************************************************

using UnityEngine;
using System.Collections;

public class CoroutineController : DDOLSingleton<CoroutineController>
{

}

//********************************************************************
// 文件名: DDOLSingleton
// 描述: 继承MonoBehaviour
// 作者: 鞠明明
// 创建时间: 4/20/2017 8:20:23 PM
//********************************************************************

using UnityEngine;
using System.Collections;

public abstract class DDOLSingleton<T> : MonoBehaviour where T : DDOLSingleton<T>
{
    protected static T _Instance = null;

    public static T Instance
    {
        get
        {
            if(_Instance==null)
            {
                GameObject go = GameObject.Find("DDOLSingleton");
                if (go == null)
                {
                    go = new GameObject("DDOLSingleton");
                    DontDestroyOnLoad(go);
                }
                _Instance = go.AddComponent<T>();
            }
            return _Instance;
        }
    }


    private void OnApplicationQuit()
    {
        _Instance = null;
    }

}


//在一个不继承Monobehaviour的类直接调用CoroutineController.Instance.StartCoroutine(方法名);

二、assetbundle 加载 粒子特效不显示

  1. 是因为系统默认不将shader打入assetbundle

  2. 选择Edit->Project Setting->Graphics 添加需要的shader

猜你喜欢

转载自blog.csdn.net/sinat_25682007/article/details/78518702