public ISharedComponent SharedComponentCreate(string id, int classId) { if (disposableComponents.TryGetValue(id, out ISharedComponent component)) { return(component); } if (classId == (int)CLASS_ID.UI_SCREEN_SPACE_SHAPE || classId == (int)CLASS_ID.UI_FULLSCREEN_SHAPE) { if (GetSharedComponent <UIScreenSpace>() != null) { return(null); } } var factory = Environment.i.world.componentFactory; ISharedComponent newComponent = factory.CreateComponent(classId) as ISharedComponent; if (newComponent == null) { return(null); } disposableComponents.Add(id, newComponent); OnAddSharedComponent?.Invoke(id, newComponent); newComponent.Initialize(this, id); return(newComponent); }
public BaseDisposable SharedComponentCreate(string id, int classId) { BaseDisposable disposableComponent; if (disposableComponents.TryGetValue(id, out disposableComponent)) { return(disposableComponent); } BaseDisposable newComponent = null; switch ((CLASS_ID)classId) { case CLASS_ID.BOX_SHAPE: { newComponent = new BoxShape(this); break; } case CLASS_ID.SPHERE_SHAPE: { newComponent = new SphereShape(this); break; } case CLASS_ID.CONE_SHAPE: { newComponent = new ConeShape(this); break; } case CLASS_ID.CYLINDER_SHAPE: { newComponent = new CylinderShape(this); break; } case CLASS_ID.PLANE_SHAPE: { newComponent = new PlaneShape(this); break; } case CLASS_ID.GLTF_SHAPE: { newComponent = new GLTFShape(this); break; } case CLASS_ID.NFT_SHAPE: { newComponent = new NFTShape(this); break; } case CLASS_ID.OBJ_SHAPE: { newComponent = new OBJShape(this); break; } case CLASS_ID.BASIC_MATERIAL: { newComponent = new BasicMaterial(this); break; } case CLASS_ID.PBR_MATERIAL: { newComponent = new PBRMaterial(this); break; } case CLASS_ID.AUDIO_CLIP: { newComponent = new DCLAudioClip(this); break; } case CLASS_ID.TEXTURE: { newComponent = new DCLTexture(this); break; } case CLASS_ID.UI_INPUT_TEXT_SHAPE: { newComponent = new UIInputText(this); break; } case CLASS_ID.UI_FULLSCREEN_SHAPE: case CLASS_ID.UI_SCREEN_SPACE_SHAPE: { if (GetSharedComponent <UIScreenSpace>() == null) { newComponent = new UIScreenSpace(this); } break; } case CLASS_ID.UI_CONTAINER_RECT: { newComponent = new UIContainerRect(this); break; } case CLASS_ID.UI_SLIDER_SHAPE: { newComponent = new UIScrollRect(this); break; } case CLASS_ID.UI_CONTAINER_STACK: { newComponent = new UIContainerStack(this); break; } case CLASS_ID.UI_IMAGE_SHAPE: { newComponent = new UIImage(this); break; } case CLASS_ID.UI_TEXT_SHAPE: { newComponent = new UIText(this); break; } case CLASS_ID.VIDEO_CLIP: { newComponent = new DCLVideoClip(this); break; } case CLASS_ID.VIDEO_TEXTURE: { newComponent = new DCLVideoTexture(this); break; } case CLASS_ID.FONT: { newComponent = new DCLFont(this); break; } case CLASS_ID.NAME: { newComponent = new DCLName(this); break; } case CLASS_ID.LOCKED_ON_EDIT: { newComponent = new DCLLockedOnEdit(this); break; } case CLASS_ID.VISIBLE_ON_EDIT: { newComponent = new DCLVisibleOnEdit(this); break; } default: Debug.LogError($"Unknown classId"); break; } if (newComponent != null) { newComponent.id = id; disposableComponents.Add(id, newComponent); OnAddSharedComponent?.Invoke(id, newComponent); } return(newComponent); }