Пример #1
0
    public static uint CreateImage(string imageName, int width, int height)
    {
        SprMgr     self = SprMgr.GetInstance();
        GameObject go   = null;// new GameObject(imageName);

        self.ImagePool.Add(self.ImageSeed, go);
        return(self.ImageSeed++);
    }
Пример #2
0
 public static bool RepresentBegin(
     int bClear,             //## 是否清除设备上当前的图形。
     uint Color              //## 如果bClear为非0值,则Color指出用什么颜色值来清除设备原来的图形。
     )
 {
     if (SprMgr.GetInstance() != null)
     {
         SprMgr.GetInstance().Swap();
     }
     zbuff = 0f;
     return(true);
 }
Пример #3
0
 // Update is called once per frame
 void FixedUpdate()
 {
     interval--;
     if (interval == 0)
     {
         nFrame++;
         interval = 60;
         Texture2D tx = SprMgr.GetInstance().LoadSpr(sprPath, nFrame);
         if (tx == null)
         {
             nFrame = -1;
             return;
         }
         Sprite newsp = Sprite.Create(tx, new Rect(0f, 0f, tx.width, tx.height), new Vector2(0.0f, 1.0f));
         sr.sprite = newsp;
     }
 }
Пример #4
0
    public static void DrawModel(long uuid, space_obj_primitive_cmd_t cmds)
    {
        IntPtr obj;

        SprMgr     self = SprMgr.GetInstance();
        GameObject go;

        if (!self.modelPool.TryGetValue(uuid, out go))
        {
            go = new GameObject();
            go.AddComponent <SkinnedMeshRenderer>();
            go.AddComponent <Animation>();
            go.AddComponent <KSMesh>();
            self.modelPool.Add(uuid, go);
        }
        go.transform.parent        = self.front.transform;
        go.transform.localPosition = new Vector3(cmds.pos.x, cmds.pos.y, cmds.pos.z);
    }
Пример #5
0
    public static bool DrawSpr(long cmd_addr, pic_cmd_t cmds)
    {
        SprMgr     self    = SprMgr.GetInstance();
        GameObject go      = self.GetSpr(cmd_addr);
        Vector3    pos     = new Vector3(cmds.pos1.x, cmds.pos1.y, cmds.pos1.z);
        bool       bReload = false;
        string     szImage = Encoding.UTF8.GetString(Encoding.Convert(GLB.GBK, Encoding.UTF8, cmds.filename));
        KSSprite   ksp;

        if (!go)
        {
            go  = new GameObject(szImage);
            ksp = go.AddComponent <KSSprite>();
            self.SprMap.Add(cmd_addr, ksp);
            //pos += new Vector3(tx.width/200, -tx.height/200, 0f);
            bReload = true;
        }
        else
        {
            ksp = go.GetComponent <KSSprite>();
            if (ksp.GetFrame() != cmds.frame_index)
            {
                bReload = true;
            }
        }
        if (bReload)
        {
            Texture2D tx = self.LoadSpr(szImage, cmds.frame_index);
            if (!tx)
            {
                Debug.LogError("Load Spr Error: " + szImage);
                return(false);
            }
            Sprite sp = Sprite.Create(tx, new Rect(0f, 0f, tx.width, tx.height), new Vector2(0.0f, 1.0f), 100.0f, 0, SpriteMeshType.FullRect);
            ksp.SetSprite(sp, cmds.frame_index);
        }

        go.transform.parent        = self.front.transform;
        go.transform.localPosition = pos;
        return(true);
    }
Пример #6
0
    public static bool DrawText(long uuid, string text, float x, float y, float z = 0f)
    {
        SprMgr     self = SprMgr.GetInstance();
        GameObject go;

        if (!self.TxtPool.TryGetValue(uuid, out go))
        {
            go = new GameObject(text);
            go.AddComponent <MeshRenderer>();
            TextMesh _tm = go.AddComponent <TextMesh>();
            _tm.characterSize = 0.04f;
            _tm.fontSize      = 30;
            self.TxtPool.Add(uuid, go);
        }
        go.transform.parent = self.front.transform;
        TextMesh tm = go.GetComponent <TextMesh>();

        tm.text = text;
        go.transform.localPosition = new Vector3(x, y, z);
        return(true);
    }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        string file = @"\UImage\第三版\ib系统\ib系统_底图.spr";

        CoreWrapper.InitFile();
        int size = CoreWrapper.GetFileSize(GLB.GBK.GetBytes(file));

        Debug.Log("size = " + size);
        byte[] data = new byte[size];
        //int read = CoreWrapper.LoadFile2(GLB.GBK.GetBytes(file), ref data, size);
        IntPtr read = CoreWrapper.LoadFile(GLB.GBK.GetBytes(file));

        Marshal.Copy(read, data, 0, size);
        Debug.Log(read);

        sr = gameObject.GetComponent <SpriteRenderer>();
        //Sprite sp = sr.sprite;
        //Color32[] colors1 = sp.texture.GetPixels32();
        //Debug.Log(colors1);


        //Color32[] colors = new Color32[100 * 100];
        //for (int i = 0; i < 100 * 100; i++)
        //{
        //    byte c = (byte)i;
        //    colors[i] = new Color32(c, c, c, c);
        //}
        //Texture2D tx = new Texture2D(100, 100);
        //tx.SetPixels32(colors);
        //Sprite newsp = Sprite.Create(tx, new Rect(0f, 0f, 100f, 100f), new Vector2(0.5f, 0.5f));

        Texture2D tx    = SprMgr.GetInstance().LoadSpr(sprPath, 0);
        Sprite    newsp = Sprite.Create(tx, new Rect(0f, 0f, tx.width, tx.height), new Vector2(0f, 1f));

        sr.sprite = newsp;
        sr.flipY  = true;
        //transform.localPosition -= new Vector3(tx.width / 200, tx.height / 200, 0f);
    }