【优化】添加判断物体是否被销毁的方法,优化可能导致黑屏卡死的问题
parent
a6e93212d0
commit
eebd99883b
|
@ -1 +1,66 @@
|
||||||
{"Setting":{"LanguagePackager":{"desc":"\u672C\u5730\u5316\u5904\u7406","versionCode":"26","isActive":"0"},"ServerVersion":{"desc":"\u7528\u4E8E\u5207\u6362\u6B63\u5F0F\u670D\u548C\u63D0\u5BA1\u670D","value":"0","versionCode":"26","isActive":"1"},"ThinkAnalysis_GetDeviceID":{"desc":"\u6570\u6570\u83B7\u53D6DeviceID\u65B9\u6CD5","versionCode":"24","isActive":"1"},"LayoutBuilderWrap":{"desc":"\u5F3A\u5236\u5237\u65B0layout\u7EC4\u4EF6\u5927\u5C0F\u7684\u65B9\u6CD5\u4FEE\u6539\u5230lua\u4E2D\u8C03\u7528","versionCode":"25","isActive":"1"},"IS_PLAY_VOICE":{"desc":"","versionCode":"1","isActive":"1"},"IS_TITLE_EFFECT_SCALE":{"desc":"","versionCode":"1","isActive":"1"},"IS_PLAY_LOGIN_VIDEO":{"desc":"","versionCode":"1","isActive":"1"},"PACKAGE_CC_CODE":{"desc":"","versionCode":"1","isActive":"1","value":"1001"},"CURVED_TEXT_CODE":{"desc":"\u662F\u5426\u53EF\u4EE5\u663E\u793A\u5F27\u5F62\u6587\u5B57","versionCode":"30","isActive":"1"},"IS_SELECT_RESLUTION":{"desc":"\u662F\u5426\u53EF\u4EE5\u9009\u62E9\u5E27\u7387","versionCode":"30","isActive":"1"}}}
|
{
|
||||||
|
"Setting": {
|
||||||
|
"LanguagePackager": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "26",
|
||||||
|
"isActive": "0"
|
||||||
|
},
|
||||||
|
"ServerVersion": {
|
||||||
|
"desc": "",
|
||||||
|
"value": "0",
|
||||||
|
"versionCode": "26",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"ThinkAnalysis_GetDeviceID": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "24",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"LayoutBuilderWrap": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "25",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"IS_PLAY_VOICE": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "1",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"IS_TITLE_EFFECT_SCALE": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "1",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"IS_PLAY_LOGIN_VIDEO": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "1",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"PACKAGE_CC_CODE": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "1",
|
||||||
|
"isActive": "1",
|
||||||
|
"value": "1001"
|
||||||
|
},
|
||||||
|
"CURVED_TEXT_CODE": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "30",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"IS_SELECT_RESLUTION": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "30",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"INNER_WEB_CONTROL": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "1",
|
||||||
|
"isActive": "1"
|
||||||
|
},
|
||||||
|
"IS_NULL": {
|
||||||
|
"desc": "",
|
||||||
|
"versionCode": "1",
|
||||||
|
"isActive": "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1341,7 +1341,14 @@ end
|
||||||
|
|
||||||
---obj必须是userdata(c#对象)
|
---obj必须是userdata(c#对象)
|
||||||
function IsNull(obj)
|
function IsNull(obj)
|
||||||
return obj == nil or obj:Equals(nil)
|
if not obj then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_NULL) then
|
||||||
|
return obj:IsNull()
|
||||||
|
else
|
||||||
|
return obj == nil or obj:Equals(nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
------- 红点相关 ----------
|
------- 红点相关 ----------
|
||||||
|
|
|
@ -203,7 +203,8 @@ function PoolManager:UnLoadAsset(resName,res, assetType)
|
||||||
--then
|
--then
|
||||||
if assetType == PoolManager.AssetType.GameObject
|
if assetType == PoolManager.AssetType.GameObject
|
||||||
and res
|
and res
|
||||||
and tostring(res) ~= "null" then
|
and tostring(res) ~= "null"
|
||||||
|
and not IsNull(res) then
|
||||||
res.transform:SetParent(self.mPoolTrans)
|
res.transform:SetParent(self.mPoolTrans)
|
||||||
if #pool.resList <= 5 then
|
if #pool.resList <= 5 then
|
||||||
table.insert(pool.resList,res)
|
table.insert(pool.resList,res)
|
||||||
|
|
|
@ -24,6 +24,7 @@ ServerConfigManager.SettingConfig = {
|
||||||
USER_PROTO = "USER_PROTO", -- 用户协议功能是否开启
|
USER_PROTO = "USER_PROTO", -- 用户协议功能是否开启
|
||||||
IS_NO_NOTICE = "IS_NO_NOTICE", -- 是否禁用公告
|
IS_NO_NOTICE = "IS_NO_NOTICE", -- 是否禁用公告
|
||||||
INNER_WEB_CONTROL = "INNER_WEB_CONTROL", -- 是否使用内置浏览器
|
INNER_WEB_CONTROL = "INNER_WEB_CONTROL", -- 是否使用内置浏览器
|
||||||
|
IS_NULL = "IS_NULL", -- 使用C#判断物体是否销毁
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ function this.GetBattleBestData(Id)
|
||||||
local battleRecord = this.GetBattleRecord(Id)
|
local battleRecord = this.GetBattleRecord(Id)
|
||||||
for _, data in pairs(battleRecord.data) do
|
for _, data in pairs(battleRecord.data) do
|
||||||
-- 怪物只显示最后一层的怪物信息
|
-- 怪物只显示最后一层的怪物信息
|
||||||
if data.info.camp == 0 then
|
if data.info and data.info.camp == 0 then
|
||||||
-- 计算最大值(不计算异妖的)
|
-- 计算最大值(不计算异妖的)
|
||||||
if data.info.type == BattleUnitType.Role then
|
if data.info.type == BattleUnitType.Role then
|
||||||
if data.damage > _MaxDamageValue then
|
if data.damage > _MaxDamageValue then
|
||||||
|
|
|
@ -47,6 +47,9 @@ function SkillCaster:OnSkillCast(skill)
|
||||||
local duration = combat.KeyFrame/1000
|
local duration = combat.KeyFrame/1000
|
||||||
|
|
||||||
local function _PlaySkill()
|
local function _PlaySkill()
|
||||||
|
if IsNull(self.owner.GameObject) then
|
||||||
|
return
|
||||||
|
end
|
||||||
-- 调用上层接口
|
-- 调用上层接口
|
||||||
if self.owner.OnSkillPlay then
|
if self.owner.OnSkillPlay then
|
||||||
self.owner:OnSkillPlay()
|
self.owner:OnSkillPlay()
|
||||||
|
|
|
@ -476,15 +476,6 @@ end
|
||||||
function CarbonScoreSortPanel:OnClose()
|
function CarbonScoreSortPanel:OnClose()
|
||||||
if callBack then callBack() end
|
if callBack then callBack() end
|
||||||
this.noneImage:SetActive(false)
|
this.noneImage:SetActive(false)
|
||||||
if this.ScrollView then
|
|
||||||
SubUIManager.Close(this.ScrollView)
|
|
||||||
end
|
|
||||||
this.ScrollView = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--界面销毁时调用(用于子类重写)
|
|
||||||
function CarbonScoreSortPanel:OnDestroy()
|
|
||||||
this.spLoader:Destroy()
|
|
||||||
for _, playerHead in pairs(_PlayerHeadList) do
|
for _, playerHead in pairs(_PlayerHeadList) do
|
||||||
playerHead:Recycle()
|
playerHead:Recycle()
|
||||||
end
|
end
|
||||||
|
@ -495,5 +486,18 @@ function CarbonScoreSortPanel:OnDestroy()
|
||||||
this.ScrollView = nil
|
this.ScrollView = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--界面销毁时调用(用于子类重写)
|
||||||
|
function CarbonScoreSortPanel:OnDestroy()
|
||||||
|
this.spLoader:Destroy()
|
||||||
|
-- for _, playerHead in pairs(_PlayerHeadList) do
|
||||||
|
-- playerHead:Recycle()
|
||||||
|
-- end
|
||||||
|
-- _PlayerHeadList = {}
|
||||||
|
-- if this.ScrollView then
|
||||||
|
-- SubUIManager.Close(this.ScrollView)
|
||||||
|
-- end
|
||||||
|
-- this.ScrollView = nil
|
||||||
|
end
|
||||||
|
|
||||||
return CarbonScoreSortPanel
|
return CarbonScoreSortPanel
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,7 @@ function this.RemainTimeDown(_timeTextExpertgo,_timeTextExpert,timeDown,str)
|
||||||
this.timer = nil
|
this.timer = nil
|
||||||
end
|
end
|
||||||
this.timer = Timer.New(function()
|
this.timer = Timer.New(function()
|
||||||
if _timeTextExpert and tostring(_timeTextExpert) ~= "null" then
|
if not IsNull(_timeTextExpert) and tostring(_timeTextExpert) ~= "null" then
|
||||||
if str then
|
if str then
|
||||||
_timeTextExpert.text = str..this.TimeStampToDateString(timeDown)
|
_timeTextExpert.text = str..this.TimeStampToDateString(timeDown)
|
||||||
else
|
else
|
||||||
|
@ -296,7 +296,7 @@ function this.RemainTimeDown(_timeTextExpertgo,_timeTextExpert,timeDown,str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if timeDown < 0 then
|
if timeDown < 0 then
|
||||||
if _timeTextExpertgo then
|
if not IsNull(_timeTextExpertgo) then
|
||||||
_timeTextExpertgo:SetActive(false)
|
_timeTextExpertgo:SetActive(false)
|
||||||
end
|
end
|
||||||
this.timer:Stop()
|
this.timer:Stop()
|
||||||
|
|
|
@ -127,7 +127,7 @@ function SingleRecruitPanel:BindEvent()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
Util.AddClick(this.dragView.gameObject, function ()
|
Util.AddClick(this.dragView.gameObject, function ()
|
||||||
if testLiveGO then
|
if not IsNull(testLiveGO) then
|
||||||
local SkeletonGraphic = testLiveGO:GetComponent("SkeletonGraphic")
|
local SkeletonGraphic = testLiveGO:GetComponent("SkeletonGraphic")
|
||||||
SkeletonGraphic.AnimationState:SetAnimation(0, "touch", false)
|
SkeletonGraphic.AnimationState:SetAnimation(0, "touch", false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -403,7 +403,11 @@ function this:UpdateBtnList()
|
||||||
tabsList = {}
|
tabsList = {}
|
||||||
end
|
end
|
||||||
for k,v in pairs(tabsList) do
|
for k,v in pairs(tabsList) do
|
||||||
tabsList[k].gameObject:SetActive(false)
|
if IsNull(tabsList[k]) then
|
||||||
|
tabsList[k] = nil
|
||||||
|
else
|
||||||
|
tabsList[k].gameObject:SetActive(false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
for k,v in ipairs(tabs) do
|
for k,v in ipairs(tabs) do
|
||||||
if not tabsList[k] then
|
if not tabsList[k] then
|
||||||
|
|
|
@ -468,8 +468,8 @@ function this:SetShow(showIndex)
|
||||||
item = self.cellItemList[j][i]
|
item = self.cellItemList[j][i]
|
||||||
index = j+(i-1)*self.fixedCount
|
index = j+(i-1)*self.fixedCount
|
||||||
dataIndex = j+(i-1 + self.dataLine)*self.fixedCount
|
dataIndex = j+(i-1 + self.dataLine)*self.fixedCount
|
||||||
|
|
||||||
if not item.go then
|
if IsNull(item.go) then
|
||||||
local go = newObject(self.item)
|
local go = newObject(self.item)
|
||||||
go.transform:SetParent(self.dragGO.transform)
|
go.transform:SetParent(self.dragGO.transform)
|
||||||
go.transform.localScale = Vector3.one
|
go.transform.localScale = Vector3.one
|
||||||
|
|
|
@ -745,7 +745,7 @@ function SingleFightPlayerView:pravite_ShakeObjOnce(go, isReverse, roleFaceDir,
|
||||||
local offSet = isReverse and 90 or 120
|
local offSet = isReverse and 90 or 120
|
||||||
offSet = offSet / math.min(Screen.width/1080, Screen.height/1920)
|
offSet = offSet / math.min(Screen.width/1080, Screen.height/1920)
|
||||||
|
|
||||||
if go then
|
if not IsNull(go) then
|
||||||
local originPos = go:GetComponent("RectTransform").anchoredPosition
|
local originPos = go:GetComponent("RectTransform").anchoredPosition
|
||||||
local value = isReverse and -1 or 1
|
local value = isReverse and -1 or 1
|
||||||
local targetPos = originPos + Vector2.New(offSet * roleFaceDir.x * value, offSet * roleFaceDir.y * value)
|
local targetPos = originPos + Vector2.New(offSet * roleFaceDir.x * value, offSet * roleFaceDir.y * value)
|
||||||
|
|
|
@ -209,7 +209,7 @@ function UpView:UpdateGoldVal()
|
||||||
local panelShowItemList = self.itemList
|
local panelShowItemList = self.itemList
|
||||||
for i = 1, _ItemMaxNum do
|
for i = 1, _ItemMaxNum do
|
||||||
if panelShowItemList[i] then
|
if panelShowItemList[i] then
|
||||||
if self.cnyList[i].gameObject then
|
if not IsNull(self.cnyList[i]) and self.cnyList[i].gameObject then
|
||||||
self.cnyList[i].gameObject:SetActive(true)
|
self.cnyList[i].gameObject:SetActive(true)
|
||||||
Util.GetGameObject(self.cnyList[i].gameObject, "icon"):GetComponent("Image").sprite = SetIcon(self.spLoader, panelShowItemList[i])
|
Util.GetGameObject(self.cnyList[i].gameObject, "icon"):GetComponent("Image").sprite = SetIcon(self.spLoader, panelShowItemList[i])
|
||||||
Util.GetGameObject(self.cnyList[i].gameObject, "addFlag"):SetActive(_IsShowPlus(panelShowItemList[i]))
|
Util.GetGameObject(self.cnyList[i].gameObject, "addFlag"):SetActive(_IsShowPlus(panelShowItemList[i]))
|
||||||
|
@ -234,7 +234,7 @@ function UpView:UpdateGoldVal()
|
||||||
self:_BindRP(panelShowItemList[i], redpot)
|
self:_BindRP(panelShowItemList[i], redpot)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if self.cnyList[i].gameObject then
|
if not IsNull(self.cnyList[i]) and self.cnyList[i].gameObject then
|
||||||
self.cnyList[i].gameObject:SetActive(false)
|
self.cnyList[i].gameObject:SetActive(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -123,7 +123,7 @@ public static class CustomSettings
|
||||||
_GT(typeof(PlayerPrefs)),
|
_GT(typeof(PlayerPrefs)),
|
||||||
_GT(typeof(Behaviour)),
|
_GT(typeof(Behaviour)),
|
||||||
_GT(typeof(MonoBehaviour)),
|
_GT(typeof(MonoBehaviour)),
|
||||||
_GT(typeof(GameObject)),
|
_GT(typeof(GameObject)).AddExtendType(typeof(UnityEngineObjectExtention)),
|
||||||
_GT(typeof(TrackedReference)),
|
_GT(typeof(TrackedReference)),
|
||||||
_GT(typeof(Application)),
|
_GT(typeof(Application)),
|
||||||
_GT(typeof(Physics)),
|
_GT(typeof(Physics)),
|
||||||
|
|
|
@ -15,4 +15,11 @@ namespace GameLogic
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static class UnityEngineObjectExtention
|
||||||
|
{
|
||||||
|
public static bool IsNull(this UnityEngine.Object o) // 或者名字叫IsDestroyed等等
|
||||||
|
{
|
||||||
|
return o == null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//this source code was auto-generated by tolua#, do not modify it
|
//this source code was auto-generated by tolua#, do not modify it
|
||||||
using System;
|
using System;
|
||||||
|
using GameLogic;
|
||||||
using LuaInterface;
|
using LuaInterface;
|
||||||
|
|
||||||
public class UnityEngine_GameObjectWrap
|
public class UnityEngine_GameObjectWrap
|
||||||
|
@ -24,6 +25,7 @@ public class UnityEngine_GameObjectWrap
|
||||||
L.RegFunction("BroadcastMessage", BroadcastMessage);
|
L.RegFunction("BroadcastMessage", BroadcastMessage);
|
||||||
L.RegFunction("SendMessageUpwards", SendMessageUpwards);
|
L.RegFunction("SendMessageUpwards", SendMessageUpwards);
|
||||||
L.RegFunction("SendMessage", SendMessage);
|
L.RegFunction("SendMessage", SendMessage);
|
||||||
|
L.RegFunction("IsNull", IsNull);
|
||||||
L.RegFunction("New", _CreateUnityEngine_GameObject);
|
L.RegFunction("New", _CreateUnityEngine_GameObject);
|
||||||
L.RegFunction("__eq", op_Equality);
|
L.RegFunction("__eq", op_Equality);
|
||||||
L.RegFunction("__tostring", ToLua.op_ToString);
|
L.RegFunction("__tostring", ToLua.op_ToString);
|
||||||
|
@ -716,6 +718,23 @@ public class UnityEngine_GameObjectWrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||||
|
static int IsNull(IntPtr L)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ToLua.CheckArgsCount(L, 1);
|
||||||
|
UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
|
||||||
|
bool o = obj.IsNull();
|
||||||
|
LuaDLL.lua_pushboolean(L, o);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return LuaDLL.toluaL_exception(L, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||||
static int op_Equality(IntPtr L)
|
static int op_Equality(IntPtr L)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue