forked from u3dkbe/kbengine_unity3d_warring
-
Notifications
You must be signed in to change notification settings - Fork 323
Expand file tree
/
Copy pathbackgroundpic.cs
More file actions
49 lines (39 loc) · 2.5 KB
/
backgroundpic.cs
File metadata and controls
49 lines (39 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using UnityEngine;
using KBEngine;
using System.Collections;
using System;
public class backgroundpic : MonoBehaviour {
public static UITexture obj = null;
void Awake ()
{
obj = GetComponent<UITexture>();
StartCoroutine(getFullTexture());
}
// Use this for initialization
void Start () {
}
IEnumerator getFullTexture(){
if(obj.mainTexture.name.IndexOf("_min") > -1)
{
string[] res = obj.mainTexture.name.Split(new char[]{'_', 'm', 'i', 'n'});
string path = "/ui/bg/" + res[0] + ".jpg";
Common.DEBUG_MSG("backgroundpic::getFullTexture: starting download backgroundpic! curr=" + obj.mainTexture.name);
WWW www = new WWW(Common.safe_url(path));
yield return www;
//if (www.error != null)
if (!String.IsNullOrEmpty(www.error))
{
Common.ERROR_MSG(www.error);
}
//else if (www.texture != null)
else if (!(System.Object.ReferenceEquals(www.texture,null)))
{
obj.mainTexture = www.texture;
}
Common.DEBUG_MSG("backgroundpic::getFullTexture: download backgroundpic is finished!");
}
}
// Update is called once per frame
void Update () {
}
}