demo下載:(待審核)
https://download.csdn.net/download/K86338236/89527924
const { ccclass, property } = cc._decorator;const enum box_color {NORMAL = 0,DASHED_LINE = 1,//虛線TRANSLUCENT = 2,//半透明
}@ccclass
export default class main extends cc.Component {@property(cc.Node)boxNode: cc.Node = null;@property(cc.Node)layerNode: cc.Node = null;/**層的父節點 */@property(cc.Node)layerRootNode: cc.Node = null;/**點擊檢測射線 */@property(cc.Node)touchNode: cc.Node = null;/**普通的顏色 */@property([cc.Material])changeMat: cc.Material[] = [];/**普通顏色第二層,半透明用 */@property([cc.Material])changeMat2: cc.Material[] = [];/**選擇狀態的顏色 */@property([cc.Material])changeMatChoose: cc.Material[] = [];@property([cc.Material])changeMatChoose2: cc.Material[] = [];/**向左旋轉45 */@property(cc.Button)leftBtn: cc.Button = null;/**向右旋轉45 */@property(cc.Button)rightBtn: cc.Button = null;/**分離、合起 */@property(cc.Button)divideBtn: cc.Button = null;/**已經修改顏色uid物體 */changeUids: string[] = [];/**當前分離狀態,是否分離 */curDivideState: boolean = false;/**當前角度 */curAngle: number = 0;/**是否動作中 */isPlay: boolean = false;/**當前角度 */choose_type: number = 0;// onLoad () {}start() {this.setAngle(-15)cc.director.getPhysics3DManager().enabled = true;this.touchNode.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);let boxArr = ["1,1|1,2|1,3|2,1|2,2|3,1",