private void constructServicesAndComponents(List <Service> services, ServiceSlice serviceSlice) { foreach (Service service in services) { CompilationUnit serviceCU = service.getServiceCU(); if (serviceCU != null && serviceCU.getGameObject() != null) { GameObject serviceGO = Instantiate(interfacePrefab, transform.position, Quaternion.identity); serviceGO.layer = LayerMask.NameToLayer("InteractionSystemLayer"); serviceGO.name = service.getName(); Vector3 cuPosition = serviceCU.getGameObject().transform.position; cuPosition.y = 0f; serviceGO.transform.position = cuPosition + new Vector3(0f, serviceSlice.height, 0f); serviceGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize); serviceGO.transform.SetParent(serviceSlice.transform); ServiceNodeScript sns = serviceGO.AddComponent <ServiceNodeScript>(); serviceGO.AddComponent <TextLabelComponent>(); ServiceLayerGO slGO = serviceCU.getGameObject().GetComponent <ServiceLayerGO>(); slGO.addServiceNode(sns); #region construct ServiceComponents List <ServiceComponent> implementingComponents = service.getImplementingComponents(); List <ServiceComponent> referencingComponents = service.getReferencingComponents(); foreach (ServiceComponent sc in implementingComponents) { CompilationUnit componentCU = sc.getImplementationCU(); GameObject scGO = Instantiate(implementationPrefab, transform.position, Quaternion.identity); scGO.layer = LayerMask.NameToLayer("InteractionSystemLayer"); scGO.name = sc.getName(); cuPosition = componentCU.getGameObject().transform.position; cuPosition.y = 0f; scGO.transform.position = cuPosition + new Vector3(0f, serviceSlice.height, 0f); scGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize); scGO.transform.SetParent(serviceSlice.transform); ServiceNodeScript scGOcomponent = scGO.AddComponent <ServiceNodeScript>(); scGO.AddComponent <TextLabelComponent>(); scGOcomponent.addConnectedServiceNode(sns); sns.addConnectedServiceNode(scGOcomponent); scGOcomponent.disableServiceNode(); ServiceLayerGO sl = componentCU.getGameObject().GetComponent <ServiceLayerGO>(); sl.addServiceNode(scGOcomponent); } foreach (ServiceComponent sc in referencingComponents) { CompilationUnit componentCU = sc.getImplementationCU(); GameObject scGO = Instantiate(referencePrefab, transform.position, Quaternion.identity); scGO.layer = LayerMask.NameToLayer("InteractionSystemLayer"); scGO.name = sc.getName(); cuPosition = componentCU.getGameObject().transform.position; cuPosition.y = 0f; scGO.transform.position = cuPosition + new Vector3(0f, serviceSlice.height, 0f); scGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize); scGO.transform.SetParent(serviceSlice.transform); ServiceNodeScript scGOcomponent = scGO.AddComponent <ServiceNodeScript>(); scGO.AddComponent <TextLabelComponent>(); scGOcomponent.addConnectedServiceNode(sns); sns.addConnectedServiceNode(scGOcomponent); scGOcomponent.disableServiceNode(); ServiceLayerGO sl = componentCU.getGameObject().GetComponent <ServiceLayerGO>(); sl.addServiceNode(scGOcomponent); } #endregion sns.disableServiceNode(); } } }