2014-07-03 46 views
0

假設我有兩個方法 - Parent和Child。當記錄Child方法時,我想知道現在正在處理哪個parentId。這意味着在Child的LogHandler方法中,我可以獲得parentId。 Unity能做到這一點嗎?如何將數據傳遞給Unity中父級方法的攔截器

[LogHandler] //Unity call handler 
    public virtual void Parent(int parentId) 
    { 
     //do something 
     Child(); 
    } 
    [LogHandler] 
    public virtual void Child() 
    { 
    } 

回答

0

如果你正在尋找如何讓一個對象的父,只需使用transform.parent.GetInstanceID()(或transform.root.GetInstanceID(),如果你想在最頂層的母公司)。

相關問題