LayaIDE2.5编辑器二次开发(参考图,修改位置,层级,透明度)


前言

提示:编辑器开发基础请参考这位大佬的文章
链接: Laya编辑器二次开发(一)找到需要操作的文件

增加layaide参考图调整位置,层级和透明度功能


一、修改LayaIDE属性面板

增加需要的操作属性在面板中
找到需要修改的文件laya.editorUI.xml

地址:D:\工具集\LayaAirIDE2.5.0\LayaAirIDE2.5.0\resources\app\out\vs\layaEditor\renders

这个文件是layaIDE的编辑器xml文件,搜索sceneColor字段,在该位置添加需要的属性

<Scene className="laya.editorUI.View" inherit="Sprite" icon="View" groups="公用,常用,宽高及位置,旋转及缩放" drag="3">
		<prop name="sceneColor" tips="参考背景颜色(实际运行中没有)" type="color" default="" group="常用" />
		<!-- ==============================需要添加的属性=========================== -->
		<prop type="group" group="常用">
			<prop name="参考x" tips="参考视图x" type="number" default="0" />
			<prop name="参考y" tips="参考视图y" type="number" default="0" />
		</prop>		
		<prop name="参考alpha" tips="参考视图透明度" type="number" default="1" group="常用"/>
		<prop name="参考显示" tips="参考视图显隐" type="bool" default="true" group="常用"/>
		<prop name="参考z" tips="参考视图层级" type="number" default="-1" group="常用"/>
		<!-- ========================================================= -->
		<prop name="texture" tips="Texture的地址,可以拖入图片到此输入框" type="string" accept="res" acceptTypes="png,jpg" default="" />
		<prop name="viewport" tips="视口大小(格式:x,y,width,height),视口外的子对象,将不被渲染" xCount="2" labels="x,y,width,height" type="string" default="" />
		<prop name="autoDestroyAtClosed" tips="场景被关闭后,是否自动销毁(销毁节点和使用到的资源),默认为false" type="bool" default="false" group="常用" />
	</Scene>

注:number属性的参数可以直接使用拖动修改数值的功能

二、修改代码

第一步

找到所需文件editor.max.js

地址:D:\工具集\LayaAirIDE2.5.0\LayaAirIDE2.5.0\resources\app\out\vs\layaEditor\h5\renders\uiviewer

注:如果不需要中文显示属性名,可以不写这段
这个文件是IDE的视图逻辑文件,搜索changeProps字段

   	if (proName=="参考x") { proName="referenceViewPositionX" }
    if (proName=="参考y") { proName="referenceViewPositionY" }
    if (proName=="参考alpha") { proName="referenceViewAlpha" }
    if (proName=="参考显示") { proName="referenceViewVisible" }
    if (proName=="参考z") { proName="referenceViewIndex" }

主要作用为将 中文属性名 转为 英文属性名

第二步

在文件中搜索setSelectedBoxLater方法
在方法中加入该代码

if(this._bgLayer != null) {
      this._bgLayer.visible = xml.props.referenceViewVisible || true;
      if(this._bgLayer.visible) {
        this._bgLayer.x = xml.props.referenceViewPositionX || 0;
        this._bgLayer.y = xml.props.referenceViewPositionY || 0;
        this._bgLayer.zOrder = xml.props.referenceViewIndex || -1;
        this._bgLayer.alpha = xml.props.referenceViewAlpha == null ? 1 : xml.props.referenceViewAlpha;
      }
    }

注:如果使用了中文属性名,并且没有在changeProps中转换,也可以直接xml.props.中文属性名,同样可以调用到

三、使用

在这里插入图片描述


  • 25
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值