Beispiel #1
0
        private List <UIElementNode> AS3_getChildren(GameObject go)
        {
            Transform[] transforms = go.GetComponentsInChildren <Transform>(true);

            List <UIElementNode> nodes = new List <UIElementNode>();

            foreach (Transform item in transforms)
            {
                if (item.parent == go.transform)
                {
                    var node = new UIElementNode();
                    node.initilize(item.gameObject, this);

                    dic[item.gameObject.name] = item.gameObject;
                    nodes.Add(node);
                }
            }
            return(nodes);
        }
Beispiel #2
0
        public void decode(GameObject go)
        {
            if (go.name.IndexOf("UI") == 0)
            {
                UIName = go.name;

                var folderName = UIName.Substring(2) + "UI";
                folderName = LowerFirstChar(folderName);
                modulePath = modulePathPrefix + folderName + "/";

                CodeExportSetting setting = go.GetComponent <CodeExportSetting>();
                if (setting != null)
                {
                    if (string.IsNullOrEmpty(setting.parentModuleName) == false)
                    {
                        modulePath = modulePathPrefix + setting.parentModuleName + "/";
                    }
                    onlyGenerateMediator = setting.onlyGenerateMediator;
                }
                else
                {
                    onlyGenerateMediator = false;
                }
            }
            else
            {
                EditorUtility.DisplayDialog("提示", "请以 UI{0} 命名", "ok");
                return;
            }

            root = new UIElementNode();
            root.initilize(go);

            //生成ViewCode
            var viewCode = new ViewCodeTemplate();

            viewCode.execute(root);

            //生成View
            var viewTemplate = new ViewTemplate();

            viewTemplate.execute(root);

            //生成Mediator
            var meditorTemplate = new MediatorTemplate();

            meditorTemplate.execute(root);

            if (onlyGenerateMediator == false)
            {
                //生成Proxy
                var proxyTemplate = new ProxyTemplate();
                proxyTemplate.execute(root);

                //生成Operater
                var operateTemplate = new OperaterTemplate();
                operateTemplate.execute(root);

                //生成Decoder
                var decoderTemplate = new DecoderTemplate();
                decoderTemplate.execute(root);
            }

            createOther(root);

            EditorUtility.DisplayDialog("提示", UIName + " 代码生成成功", "确定");
        }