Пример #1
0
    private void _AnalysisGameobject(GameObject go, ScriptTrunk parent)
    {
        if (go == null)
        {
            return;
        }

        ScriptTrunk scriptTrunk = new ScriptTrunk();

        parent.scriptTrunks.Add(scriptTrunk);
        scriptTrunk.name  = go.name;
        scriptTrunk.path  = parent.isRoot ? go.name : string.Format("{0}/{1}", parent.path, go.name);
        scriptTrunk.depth = parent.depth + 1;

        ScriptEntry scriptEntry = new ScriptEntry();

        scriptTrunk.scriptEntries.Add(scriptEntry);
        scriptEntry.type = "GameObject";

        Component[] components = go.GetComponents <Component>();
        for (int i = 0; i < components.Length; ++i)
        {
            scriptEntry = new ScriptEntry();
            scriptTrunk.scriptEntries.Add(scriptEntry);
            scriptEntry.type = components[i].GetType().Name;
        }

        for (int i = 0; i < go.transform.childCount; ++i)
        {
            _AnalysisGameobject(go.transform.GetChild(i).gameObject, scriptTrunk);
        }
    }
Пример #2
0
    private void AnalysisGameobject(GameObject go)
    {
        if (go == null)
        {
            return;
        }

        scriptTrunkRoot        = new ScriptTrunk();
        scriptTrunkRoot.name   = go.name;
        scriptTrunkRoot.path   = string.Empty;
        scriptTrunkRoot.isRoot = true;
        scriptTrunkRoot.depth  = 0;

        ScriptEntry scriptEntry = new ScriptEntry();

        scriptTrunkRoot.scriptEntries.Add(scriptEntry);
        scriptEntry.type = "GameObject";

        Component[] components = go.GetComponents <Component>();
        for (int i = 0; i < components.Length; ++i)
        {
            scriptEntry = new ScriptEntry();
            scriptTrunkRoot.scriptEntries.Add(scriptEntry);
            scriptEntry.type = components[i].GetType().Name;
        }

        _AnalysisGameobject(selectedObject, scriptTrunkRoot);
    }