# adding a StaticMeshComponent to another custom SceneComponent derrived class

**URL:** <https://forums.unrealengine.com/t/adding-a-staticmeshcomponent-to-another-custom-scenecomponent-derrived-class/37594>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [August 4, 2015, 8:25pm UTC](https://forums.unrealengine.com/t/adding-a-staticmeshcomponent-to-another-custom-scenecomponent-derrived-class/37594 "2015-08-04T20:25:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fkkcloud](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@fkkcloud](https://forums.unrealengine.com/u/fkkcloud)\
**Post date:** [August 4, 2015, 8:25pm UTC](https://forums.unrealengine.com/t/adding-a-staticmeshcomponent-to-another-custom-scenecomponent-derrived-class/37594/1 "2015-08-04T20:25:55Z")

</div>

So, I am adding a SceneComponent to an another custom SceneComponent derrived class like so,

in header

```auto

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "UI Indiactor")
class UStaticMeshComponent* ButtonIndicatorComp;
 

```

in cpp

```auto

UStaticMeshComponent* IndicatorComp = ConstructObject<UStaticMeshComponent>(UStaticMeshComponent::StaticClass(), this);
//IndicatorComp->AttachTo(this);
ButtonIndicatorComp = IndicatorComp; // pointer reference to be persist throughout the game.

```

And it seems to work but when I try to save… below error occurred.

> [@](#):
>
> Can’t save …/…/…/ShooterGame/Content/Maps/Design/Empty\_MP\_UI.umap: Graph is linked to private object(s) in an external package. External Object(s): StaticMeshComponent\_1449  
> Try to find the chain of references to that object (may take some time)?

What would be my best bet to go over this problem?

---

<div class="post-metadata">

**Author:** ![Chooka](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chooka](https://forums.unrealengine.com/u/Chooka)\
**Post date:** [August 5, 2015, 8:24am UTC](https://forums.unrealengine.com/t/adding-a-staticmeshcomponent-to-another-custom-scenecomponent-derrived-class/37594/2 "2015-08-05T08:24:15Z")

</div>

change your

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = “UI Indiactor”)

to  
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = “UI Indiactor”, meta = (AllowPrivateAccess = “true”))

or put your property in the public section of your class

---

<div class="post-metadata">

**Author:** ![fkkcloud](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@fkkcloud](https://forums.unrealengine.com/u/fkkcloud)\
**Post date:** [August 5, 2015, 6:55pm UTC](https://forums.unrealengine.com/t/adding-a-staticmeshcomponent-to-another-custom-scenecomponent-derrived-class/37594/3 "2015-08-05T18:55:32Z")

</div>

Hi Chooka,

changing the UPROPERTY like that is not changing the situation…

It was under the public as well…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [August 7, 2015, 4:07pm UTC](https://forums.unrealengine.com/t/adding-a-staticmeshcomponent-to-another-custom-scenecomponent-derrived-class/37594/4 "2015-08-07T16:07:52Z")

</div>

Hey JaeYoo-

If the construction of the component is taking place inside the class constructor then you will want to use CreateDefaultSubobject instead of ConstructObject. Additionally, since you declared the ButtonIndicatorComp in your header file, you can use this in the construction call rather than creating a new pointer and then setting the new pointer to ButtonIndicatorComp.
