future 1 年間 前
コミット
c4f5176b07
2 ファイル変更13 行追加0 行削除
  1. 2 0
      assets/data/data.ts
  2. 11 0
      assets/script/run/widget/widget_base.ts

+ 2 - 0
assets/data/data.ts

@@ -13,6 +13,8 @@ export class attributes_data{
     public z:number = 0;
     public width:number = 0;
     public height:number = 0;
+    public anchor_x:number = 0.5;
+    public anchor_y:number = 0.5;
     public rotation:number = 0;
     public src:string = "";
     public src_name:string = "";

+ 11 - 0
assets/script/run/widget/widget_base.ts

@@ -30,6 +30,17 @@ export class widget_base extends Component {
         this.mData = data;
         this.icon.getComponent(UITransform).contentSize = new Size(this.mData.att.width,this.mData.att.height)
         this.icon.position = new Vec3(this.mData.att.x,this.mData.att.y)
+
+        var anchor_x = 0.5
+        if(this.mData.att.anchor_x!=undefined&&this.mData.att.anchor_x!=null) {
+            anchor_x = this.mData.att.anchor_x
+        } 
+        var anchor_y = 0.5
+        if(this.mData.att.anchor_x!=undefined&&this.mData.att.anchor_x!=null) {
+            anchor_y = this.mData.att.anchor_y
+        }
+        this.icon.getComponent(UITransform).setAnchorPoint(anchor_x, anchor_y)
+
         if(this.mData.att.rotation == undefined || this.mData.att.rotation == null) {
             this.icon.angle = 0
         } else {