public override void BindEntityModel(DisplayableEntityModel model) { base.BindEntityModel(model); this.model = base.model as TransformationQuadModel; this.model.meshFilter = GetComponent <MeshFilter>(); this.model.meshCollider = GetComponent <MeshCollider>(); }
public void UpdateIndicatorSize() { if (InteractiveGameObjectCollection.Instance.holdingInteractiveGo == null) { return; } DisplayableEntityModel holdingGO = InteractiveGameObjectCollection.Instance.holdingInteractiveGo; Camera worldCamera = MainManager.Instance.worldCamera; float distance = Vector3.Distance(worldCamera.transform.position, holdingGO.position); float screenWidth_WorldSpace = Vector3.Distance(worldCamera.ViewportToWorldPoint(new Vector3(0.05f, 0, distance)), worldCamera.ViewportToWorldPoint(new Vector3(0, 0, distance))); float size = screenWidth_WorldSpace; indicatorSize = size; indicatorArray.ForEach((indicator) => { Transform[] verticesArr = indicator.model.view.GetComponentsInChildren <Transform>(); for (int i = 0; i != verticesArr.Length; ++i) { if (verticesArr[i].name != "XAxis" && verticesArr[i].name != "YAxis" && verticesArr[i].name != "ZAxis" && verticesArr[i].name != "Center") { continue; } verticesArr[i].localScale = new Vector3(size, size, size); } }); }
public override void BindEntityModel(DisplayableEntityModel model) { base.BindEntityModel(model); this.model = base.model as CameraModel; this.model.lineRenders = GetComponentsInChildren <LineRenderer>().ToList(); this.model.camera = GetComponentInChildren <Camera>(); }
public EntityController CreateEntityController(string modelTypeName, string assetID) { Type modelType = Type.GetType(modelTypeName); DisplayableEntityModel model = Activator.CreateInstance(modelType) as DisplayableEntityModel; model.assetID = assetID; return(CreateEntityController(model)); }
public void RemoveChild(DisplayableEntityModel interactiveGO) { if (interactiveGO == null) { return; } interactiveGO?.SetParent(model?.parent); }
private void OnSelectedGOUpdated(DisplayableEntityModel oldInteractiveGo, DisplayableEntityModel newInteractiveGO) { currentIndicator = this[InteractiveManager.Instance.interactMethod]; currentIndicator.RemoveChild(oldInteractiveGo); currentIndicator.AddChild(newInteractiveGO); UpdateIndicatorSize(); }
public void SelectGameObject(DisplayableEntityModel GO) { if (holdingInteractiveGo == GO) { return; } DisplayableEntityModel old = holdingInteractiveGo; holdingInteractiveGo = GO; OnHoldingInteractiveGOUpdated?.Invoke(old, holdingInteractiveGo); }
public void CombineMVC(DisplayableEntityModel model, EntityView view, DisplayableEntityController controller) { view.BindEntityModel(model); model.BindEntityView(view); controller.BindEntityModel(model); model.BindEntityController(controller); view.BindEntityController(controller); controller.Init(); }
private EntityController CreateEntityController(DisplayableEntityModel model) { LoadConfigData(model); GameObject gObj = Instantiate(model.prefabPath); EntityView view = gObj.AddComponent(model.GetViewType()) as EntityView; DisplayableEntityController controller = Activator.CreateInstance(model.GetControllerType()) as DisplayableEntityController; CombineMVC(model, view, controller); return(controller); }
public void AddChild(DisplayableEntityModel interactiveGO) { // Make thisTransform have the same transform with the interactiveGO // in order to sync transform state model.parent = interactiveGO; model.localRotation = Quaternion.identity; model.localPosition = Vector3.zero; model.localScale = interactiveGO == null ? Vector3.one : interactiveGO.localScale.GetInverse(); model.parent = interactiveGO?.parent; model.active = interactiveGO != null; interactiveGO?.SetParent(model); }
public EntityController CreateEntityController(Type modelType, Type viewType, Type controllerType, string assetID) { DisplayableEntityModel model = Activator.CreateInstance(modelType) as DisplayableEntityModel; model.assetID = assetID; LoadConfigData(model); GameObject gObj = Instantiate(model.prefabPath); EntityView view = gObj.AddComponent(viewType) as EntityView; DisplayableEntityController controller = Activator.CreateInstance(controllerType) as DisplayableEntityController; CombineMVC(model, view, controller); return(controller); }
public virtual void BindEntityModel(DisplayableEntityModel model) { this.model = model; // Sync the model state model.localPosition = transform.localPosition; model.localRotation = transform.localRotation; model.localScale = transform.localScale; model.OnLocalPositionUpdated += SetLocalPosition; model.OnLocalRotationUpdated += SetLocalRotation; model.OnLocalScaleUpdated += SetLocalScale; model.OnParentUpdated += SetParent; model.OnActiveUpdated += SetActive; }
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 void SetParent(DisplayableEntityModel model, bool stayWorldPosition = true) { if (stayWorldPosition) { Vector3 deltaPos = this.position - (model != null ? model.position : Vector3.zero); this.localPosition = deltaPos; Quaternion deltaRot = (model != null ? Quaternion.Inverse(model.rotation) : Quaternion.identity) * this.rotation; this.localRotation = deltaRot; Vector3 deltaScale = this.lossyScale.Divide(model != null ? model.lossyScale : Vector3.one); this.localScale = deltaScale; } m_parent = model; model?.childrenList.Add(this); OnPositionUpdated?.Invoke(position); // Modify the parent may changed the global position, so invoke the event OnParentUpdated?.Invoke(model); }
private void OnSelectedGoUpdated(DisplayableEntityModel oldGbj, DisplayableEntityModel newGbj) { componentList.ForEach(component => component.active = (newGbj != null && newGbj == component.targetGameObject)); }
private void UnRegisterControllerHandle(DisplayableEntityModel targetModel) { targetModel.OnLocalPositionUpdated -= UpdateUIPositionData; targetModel.OnLocalRotationUpdated -= UpdateUIRotationData; targetModel.OnLocalScaleUpdated -= UpdateUIScaleData; }
public override void BindEntityModel(DisplayableEntityModel model) { base.BindEntityModel(model); this.model = base.model as ClearColorModel; this.model.OnColorUpdated += UpdateCameraClearColor; }
public override void BindEntityModel(EntityModel model) { base.BindEntityModel(model); this.model = base.model as DisplayableEntityModel; }
public virtual void SetIndicatorAxis(string axis) { indicatorAxisTrans = indicator?.model.view.transform.Find(axis); targetModel = indicator?.model; }
public override void BindEntityModel(DisplayableEntityModel model) { base.BindEntityModel(model); this.model = model as HierarchyGOModel; this.model.OnGONameChanged += SetGoName; }
public override void BindEntityModel(DisplayableEntityModel model) { base.BindEntityModel(model); this.model = base.model as TriangleModel; this.model.meshFilter = GetComponent <MeshFilter>(); }
public void AddInteractiveGo(DisplayableEntityModel model) { interactiveGo.Add(model); OnInteractiveGoCreated?.Invoke(model); Debug.Log("interactiveGO name is " + interactiveGo.Count); }
protected override void InitProcess() { base.InitProcess(); interactiveGo = new List <DisplayableEntityModel>(); holdingInteractiveGo = null; }
protected virtual void SetParent(DisplayableEntityModel trans) { // all the local transform properties should be handled by DisplayableModel rather than Unity Engine thisTransform.SetParent(trans?.view?.transform, false); }
private void OnSelectedGoUpdated(DisplayableEntityModel oldGbj, DisplayableEntityModel newGbj) { snippetViews.ForEach(view => view.Switch(newGbj != null && newGbj == view.model.targetGameObject)); }
public override void BindEntityModel(DisplayableEntityModel model) { base.BindEntityModel(model); }
public override void BindEntityModel(DisplayableEntityModel model) { base.BindEntityModel(model); this.model = base.model as ComponentModel; inputFields = GetComponentsInChildren <InputField>().ToList(); }