Ejemplo n.º 1
0
        private void CreateUIPanelCode(GameObject uiPrefab, string uiPrefabPath)
        {
            if (null == uiPrefab)
            {
                return;
            }

            var behaviourName = uiPrefab.name;

            var strFilePath = CodeGenUtil.GenSourceFilePathFromPrefabPath(uiPrefabPath, behaviourName);

            if (File.Exists(strFilePath) == false)
            {
                RegisteredTemplateGeneratorsFactory.RegisterTemplate <PanelCodeData, UIPanelDataTemplate>();
                RegisteredTemplateGeneratorsFactory.RegisterTemplate <PanelCodeData, UIPanelTemplate>();

                var factory = new RegisteredTemplateGeneratorsFactory();

                var generators = factory.CreateGenerators(new UIGraph(), UIMarkCollector.mPanelCodeData);

                CompilingSystem.GenerateFile(new FileInfo(strFilePath), new CodeFileGenerator(UIKitSettingData.GetProjectNamespace())
                {
                    Generators = generators.ToArray()
                });

                RegisteredTemplateGeneratorsFactory.UnRegisterTemplate <PanelCodeData>();
            }

            CreateUIPanelDesignerCode(behaviourName, strFilePath);
            Debug.Log(">>>>>>>Success Create UIPrefab Code: " + behaviourName);
        }
Ejemplo n.º 2
0
        private void CreateUIPanelCode(GameObject uiPrefab, string uiPrefabPath, PanelCodeInfo panelCodeInfo)
        {
            if (null == uiPrefab)
            {
                return;
            }

            var behaviourName = uiPrefab.name;

            var strFilePath = CodeGenUtil.GenSourceFilePathFromPrefabPath(uiPrefabPath, behaviourName);

            if (mScriptKitInfo.IsNotNull())
            {
                if (File.Exists(strFilePath) == false)
                {
                    if (mScriptKitInfo.Templates.IsNotNull() && mScriptKitInfo.Templates[0].IsNotNull())
                    {
                        mScriptKitInfo.Templates[0].Generate(strFilePath, behaviourName, UIKitSettingData.GetProjectNamespace(), null);
                    }
                }
            }
            else
            {
                if (File.Exists(strFilePath) == false)
                {
                    UIPanelTemplate.Write(behaviourName, strFilePath, UIKitSettingData.Load().Namespace, UIKitSettingData.Load());
                }
            }

            CreateUIPanelDesignerCode(behaviourName, strFilePath, panelCodeInfo);
            Debug.Log(">>>>>>>Success Create UIPrefab Code: " + behaviourName);
        }