public void CreateCodeSnippet(string snippetID, InteractiveGameObjectModel model) { Type modelType = ReflectionManager.Instance.GetAssetType(snippetID, "code_snippet_", "CodeSnippetModel") ?? typeof(CodeSnippetModel); Type viewType = ReflectionManager.Instance.GetAssetType(snippetID, "code_snippet_", "CodeSnippetView") ?? typeof(CodeSnippetView); Type controllerType = ReflectionManager.Instance.GetAssetType(snippetID, "code_snippet_", "CodeSnippetController") ?? typeof(CodeSnippetController); CodeSnippetModel codeModel = (Activator.CreateInstance(modelType) as CodeSnippetModel); codeModel.assetID = snippetID; codeModel.targetGameObject = model; CodeSnippetController codeController = Activator.CreateInstance(controllerType) as CodeSnippetController; codeController.model = codeModel; GameResourceManager.Instance.LoadConfigData(codeModel); CodeSnippetView codeView = Activator.CreateInstance(viewType) as CodeSnippetView; codeView.model = codeModel; codeView.controller = codeController; codeView.inputFields = CodeBlockManager.Instance.PopEditablePart(codeModel.tag, codeModel.dataCount); Debug.Log("Pop count is " + codeModel.dataCount); codeController.InitCodeSnippet(); codeView.InitCodeSnippet(); snippetViews.Add(codeView); }
public ComponentModel CreateComponent(string componentID, InteractiveGameObjectModel targetGO, bool autoHide = true) { Type modelType = ReflectionManager.Instance.GetAssetType(componentID, "component_", "ComponentModel") ?? typeof(ComponentModel); Type viewType = ReflectionManager.Instance.GetAssetType(componentID, "component_", "ComponentView") ?? typeof(ComponentView); Type controllerType = ReflectionManager.Instance.GetAssetType(componentID, "component_", "ComponentController") ?? typeof(ComponentController); ComponentModel component = GameResourceManager.Instance.CreateEntityController(modelType, viewType, controllerType, componentID).model as ComponentModel; component.targetGameObject = targetGO; componentList.Add(component); component.view.transform.SetParent(componentGroup, false); (component.controller as ComponentController).InitComponent(); (component.view as ComponentView).InitComponent(); component.active = !autoHide; return(component); }
private void OnNewInteractiveGOCreated(DisplayableEntityModel model) { InteractiveGameObjectModel targetModel = model as InteractiveGameObjectModel; HierarchyGOController hierarchyGO = GameResourceManager.Instance.CreateEntityController <HierarchyGOModel>("hierarchy_go") as HierarchyGOController; HierarchyGOModel hierarchyModel = hierarchyGO.model; hierarchyCtlList.Add(hierarchyGO); targetModel.hierarchyGO = hierarchyGO.model; hierarchyModel.attachedGO = model; hierarchyModel.goName = targetModel.name; Transform parent = (targetModel.parent as InteractiveGameObjectModel)?.hierarchyGO?.view.transform.Find("Children") ?? hierarchyGOGroup; hierarchyModel.view.transform.SetParent(parent, false); }
public override void BindEntityModel(EntityModel model) { base.BindEntityModel(model); this.model = model as InteractiveGameObjectModel; }