2

error CS0266: Cannot implicitly convert type INGUIAtlas' toUIAtlas'. An explicit conversion exists (are you missing a cast?)

В начале была ошибка с NGUI, но после обновления NGUI другая ошибка исчезла, но эта осталась! Искал как решить, но так и не нащел.

Возникает вот в этой части.

private UIAtlas startatlas;
    {
        m_sprite = this.GetComponent<UISprite>();
        startatlas = m_sprite.atlas;
        spritenames = startatlas.GetListOfSprites();
        m_trans = this.transform;
    } 

Вот скрипт полностью!

using UnityEngine;
using System.Collections;

public enum AnimType
{
    Once,
    Loop
}
public enum Dir
{
    Up=0,
    Right=90,
    Down=180,
    Left=270
}
public class StartLogAnim : MonoBehaviour {
    private UIAtlas startatlas;
    public AnimType type;
    public float Delaytime;
    public int FrameRate;
    private float timeperframe;
    public int startindex;
    public int endindex;
    private int FrameNum;
    private int currentframe;
    private UISprite m_sprite;
    private BetterList<string> spritenames;
    public bool NeedRotate;
    public bool NeedSnap;
    public bool NeedTranslate;
    public Dir targettdir;
    public Dir[] currentdir;
    private Transform m_trans;
    public Vector3[] TranPos;
    void Awake()
    {
        m_sprite = this.GetComponent<UISprite>();
        startatlas = m_sprite.atlas;
        spritenames = startatlas.GetListOfSprites();
        m_trans = this.transform;
    }
    void Start()
    {
        currentframe = 0;
        FrameNum = endindex - startindex;
        timeperframe = 1f / FrameRate;
        StartCoroutine("StartAnim");
    }
    IEnumerator StartAnim()
    {
        yield return new WaitForSeconds(Delaytime);

        if (type == AnimType.Once)
        {
            do
            {
                yield return new WaitForSeconds(timeperframe);
                currentframe++;
                m_sprite.spriteName = spritenames[currentframe+startindex];
                if (NeedSnap)
                {
                    UISpriteData temp = startatlas.GetSprite(m_sprite.spriteName);
                    m_sprite.width = temp.width;
                    m_sprite.height = temp.height;
                }
                if (NeedRotate)
                {
                    m_trans.rotation = Quaternion.Euler(Vector3.forward * (int)(currentdir[currentframe] - targettdir));
                }
                if (NeedTranslate)
                {
                    m_trans.localPosition = TranPos[currentframe];
                }
            }
            while (currentframe < FrameNum);
        }
        else
        {
            do
            {
                yield return new WaitForSeconds(timeperframe);
                currentframe++;
                if (currentframe == FrameNum)
                    currentframe = 0;
                m_sprite.spriteName = spritenames[currentframe+startindex];
                if (NeedSnap)
                {
                    UISpriteData temp = startatlas.GetSprite(m_sprite.spriteName);
                    m_sprite.width = temp.width;
                    m_sprite.height = temp.height;

                }
                if (NeedRotate)
                {
                    m_trans.rotation = Quaternion.Euler(Vector3.forward * (int)(currentdir[currentframe] - targettdir));
                }
                if (NeedTranslate)
                {
                    m_trans.localPosition = TranPos[currentframe];
                }
            }
            while (true);
        }
    }
    void EndAnim()
    {
        StopCoroutine("StartAnim");
    }
}

1 ответ 1

1

Вы пытаетесь присвоить в переменную типа UIAtlas нечто другого типа, INGUIAtlas судя по ошибке

попробуйте поменять тип переменной c

private UIAtlas startatlas;

на

private INGUIAtlas startatlas;
2
  • Спасибо ошибка исчезла!
    – Jon
    12 мар 2019 в 21:38
  • правдо теперь, все что им вызывалось перестало отображаться!
    – Jon
    12 мар 2019 в 21:45

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими условиями использования и подтверждаете, что прочитали и поняли наши политику конфиденциальности и нормы поведения.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.