网易洞见丨显示隐藏物体、OnMouseDown

版权声明:欢迎转载,转载请注明出处 https://blog.csdn.net/weixin_38239050/article/details/82828865

需注意:触发OnMouseDown的物体需添加Collider

local BPB = {};
 
function BPB:Start()
    self.hide = World.Entity.FindEntity("StuffRoot");
    self.hide:SetEnabled( false )
end
 
 
function BPB:OnMouseUp()
 
    self.hide:SetEnabled( true )
end
 
 
function BPB:New( entity )
	if self ~= BPB then return nil, "First argument must be self." end
	local new_instance = setmetatable( {} , { __metatable = {}, __index = BPB } );
	new_instance.entity = entity;
	new_instance.rotation = entity:GetLocalRotation():EulerAngles();
	new_instance.scale = entity:GetLocalScale();
	new_instance.position = World.Vector3.New(0,0,0);
	return new_instance;
end
 
return BPB;

PS:

1、不要管Unity报Lua错,放到手机上可运行

2、注意:不要忘记每个脚本都要写最后的function  

Unity能实现,手机不实现效果,网易方建议:

1.排查log一下有没有获取到这个物体,尽量不要有在一个场景里不要有同名物体;

2.gameobject的隐藏使用 SetVisible(),UI的隐藏使用SetEnabled(),这个可以搜索一下demo中的脚本理解  

实际:该用冒号的时候,用了.  导致Unity可行,手机端不可行

猜你喜欢

转载自blog.csdn.net/weixin_38239050/article/details/82828865
今日推荐