Exemplo n.º 1
0
        public static ToolboxConfig Load()
        {
            ToolboxConfig config = BlockResMgr.Get().LoadToolboxConfig();

            foreach (var category in config.BlockCategoryList)
            {
                category.Init();
            }
            return(config);
        }
Exemplo n.º 2
0
        public void Init(Workspace workspace, ToolboxConfig config)
        {
            mWorkspace = workspace;
            mConfig    = config;

            Build();

            mWorkspace.VariableMap.AddObserver(new VariableObserver(this));
            mWorkspace.ProcedureDB.AddObserver(new ProcedureObserver(this));
        }
Exemplo n.º 3
0
        public UGUI.ToolboxConfig LoadToolboxConfig()
        {
            if (m_ToolboxFiles == null || m_ToolboxFiles.Count == 0)
            {
                Debug.LogError("Load Toolbox config failed. Please assign toolbox config files to BlockResSettings.asset.");
                return(null);
            }

            var configSelected = m_ToolboxFiles.FindAll(file => file.Selected);

            if (configSelected.Count == 0)
            {
                Debug.LogWarning("Please select a toolbox config file in BlockResSettings.asset. Default select \'default\'.");
                configSelected.Add(m_ToolboxFiles.Find(file => file.IndexName == "default"));
            }
            else if (configSelected.Count > 1)
            {
                Debug.LogWarning("You have selected more than one toolbox config files in BlockResSettings.asset. The first one will be used.");
            }

            var       resParam  = configSelected[0];
            TextAsset textAsset = null;

            switch (m_LoadType)
            {
            case BlockResLoadType.Assetbundle:
                if (mABSyncLoad != null)
                {
                    textAsset = mABSyncLoad(resParam.ResName) as TextAsset;
                }
                break;

            case BlockResLoadType.Resources:
                textAsset = Resources.Load <TextAsset>(resParam.ResName);
                break;

            case BlockResLoadType.Serialized:
                textAsset = resParam.TextFile;
                break;
            }

            if (textAsset == null)
            {
                return(null);
            }

            UGUI.ToolboxConfig toolboxConfig = JsonUtility.FromJson <UGUI.ToolboxConfig>(textAsset.text);
            if (m_LoadType == BlockResLoadType.Assetbundle && mABUnload != null)
            {
                mABUnload(resParam.ResName);
            }

            return(toolboxConfig);
        }
Exemplo n.º 4
0
        public static ToolboxConfig Load(string configName)
        {
            ToolboxConfig config = BlockResMgr.Get().LoadToolboxConfig(configName);

            if (config == null)
            {
                throw new Exception("Can\'t load ToolboxConfig: " + configName);
            }

            foreach (var category in config.BlockCategoryList)
            {
                category.Init();
            }
            return(config);
        }
Exemplo n.º 5
0
        public UGUI.ToolboxConfig LoadToolboxConfig(string configName)
        {
            if (m_ToolboxFiles == null || m_ToolboxFiles.Count == 0)
            {
                return(null);
            }

            UGUI.ToolboxConfig toolboxConfig = null;
            TextAsset          textAsset     = null;

            foreach (BlockTextResParam resParam in m_ToolboxFiles)
            {
                if (string.Equals(configName, resParam.IndexName))
                {
                    switch (m_LoadType)
                    {
                    case BlockResLoadType.Assetbundle:
                        if (mABSyncLoad != null)
                        {
                            textAsset = mABSyncLoad(resParam.ResName) as TextAsset;
                        }
                        break;

                    case BlockResLoadType.Resources:
                        textAsset = Resources.Load <TextAsset>(resParam.ResName);
                        break;

                    case BlockResLoadType.Serialized:
                        textAsset = resParam.TextFile;
                        break;
                    }

                    if (textAsset != null)
                    {
                        toolboxConfig = JsonUtility.FromJson <UGUI.ToolboxConfig>(textAsset.text);
                        if (m_LoadType == BlockResLoadType.Assetbundle && mABUnload != null)
                        {
                            mABUnload(resParam.ResName);
                        }
                    }
                    break;
                }
            }
            return(toolboxConfig);
        }
Exemplo n.º 6
0
        public void BindModel(Workspace workspace)
        {
            if (mWorkspace != null)
            {
                UnBindModel();
            }

            mWorkspace = workspace;

            RectTransform codingAreaTrans = m_CodingArea.GetComponentInParent <ScrollRect>().transform as RectTransform;

            codingAreaTrans.offsetMin = new Vector2(((RectTransform)m_Toolbox.transform).sizeDelta.x, codingAreaTrans.offsetMin.y);

            m_Toolbox.Init(workspace, ToolboxConfig.Load(m_ToolboxConfig));

            m_RunBtn.onClick.AddListener(RunCode);

            if (workspace.TopBlocks.Count > 0)
            {
                BuildViews();
            }
        }