Ejemplo n.º 1
0
    static string GetScriptString(GPrefabInstance firstTarget)
    {
        string script = "";
        GFrame frame  = firstTarget.GetComponentInParent <GFrame>();

        if (frame)
        {
            //script += "findPath = \"" + GUtility.GetPath(frame.transform, firstTarget.transform) + "\";\n";
            script += "trans = frame.Find(\"" + GUtility.GetPath(frame.transform, firstTarget.transform) + "\");\n";
        }
        GWidget prefab = firstTarget.prefab;

        for (int i = 0; i < prefab.exportToScriptInfos.Count; i++)
        {
            GExportToScriptInfo property = prefab.exportToScriptInfos[i];
            string path = GUtility.GetPath(firstTarget.transform, property.target.transform);
            if (path.StartsWith("/"))
            {
                path = path.Substring(1);
            }
            script += "trans.Find(\"" + path + "\").";
            script += "GetComponent <" + property.type + "> ();";
            script += "//" + property.rename + "\n";
        }
        return(script);
    }
Ejemplo n.º 2
0
    static string GetScriptString2(GPrefabInstance firstTarget)
    {
        string script = "";
        GFrame frame  = firstTarget.GetComponentInParent <GFrame>();

        if (frame)
        {
            script += "相对于Frame的路径:\n";
            script += "    \"" + GUtility.GetPath(frame.transform, firstTarget.transform) + "\"\t//" + GetTypes(firstTarget.prefab.transform) + "\n";
        }
        script += "\n";
        GWidget prefab = firstTarget.prefab;

        script += "内部结构:\n";
        script += GetTreeString(prefab.transform, "    ");
        return(script);
    }
Ejemplo n.º 3
0
    static string CreateBindScript(GFrame frame)
    {
        string result = "";

        //绑定函数
        result += "public void BindProperty(Transform frame)\n";
        result += "{\n";
        ForEachProperty(frame, (GPrefabInstance loader, GRuntimeLib lib) => {
            if (lib)
            {
                result += "    " + GetName(loader.name) + " = frame.Find(\"" + GUtility.GetPath(frame.transform, loader.transform) + "\").GetComponent<" + lib.GetType().Name + ">();";
                result += "\n";
            }
        });
        result += "}\n";
        return(result);
    }