コード例 #1
0
        public override void set(Dictionary<string,string> param)
        {
            if (this.rootObject == null) {
                this.init (param);
            }

            string text = this.param["val"];

            if (this.param ["cut"] != "") {
                int cut = int.Parse (this.param ["cut"]);
                if (cut < text.Length) {
                    text = text.Substring (0,cut);

                    this.param ["val"] = text;

                }
            }

            this.rootObject.GetComponentInChildren<Text> ().text = text;

            //イメージ ここのpathは廃止の方向で
            if (this.param.ContainsKey ("path") && this.param ["path"] == "true") {

                if (this.param ["storage"] != "") {

                    #if(!UNITY_WEBPLAYER)

                    /*
                    byte[] bytes = File.ReadAllBytes(this.param["storage"]);

                    Texture2D texture = new Texture2D (0, 0);
                    texture.LoadImage (bytes);
                    this.targetButton.image = texture;
                    */

                    #else

                    #endif

                } else {
                    //画像がない場合はデフォルトの未設定のファイルを見せるか。。
                }

            } else {

                if (param ["storage"] != "") {

                    string filename = this.imagePath + param ["storage"];
                    this.filename = filename;
                    //Sprite imageSprite = Resources.Load<Sprite>(filename);
                    FileManager fm = new FileManager(new FileLoader());
                    Sprite imageSprite = fm.LoadSprite(filename);

                    //scale の調整
                    this.targetButton.image.overrideSprite = imageSprite;
                    this.targetButton.image.SetNativeSize ();

                }

                //width の設定
                if (param["width"] !="" && param["height"] !="" ) {
                    this.targetButton.GetComponent<RectTransform> ().sizeDelta = new Vector2(float.Parse (param ["width"]),float.Parse (param ["height"]));
                }

            }

            //クリックされた時
            this.targetButton.onClick.AddListener (() => {

                Debug.Log("clicked---:"+this.rootObject.name);
                this.gameManager.eventManager.checkEvent(this.rootObject.name,"click");

                //この次のイベントは止める check
                //StatusManager.isEventButtonStop = true;
                StatusManager.inUiClick = true;
                //イベントチェック

                //Debug.Log ("Clicked.-------------------");

            });
        }
コード例 #2
0
 private Sprite LoadSprite(string filename)
 {
     var fm = new FileManager(new FileLoader());
     return fm.LoadSprite(filename);
 }