x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

When using FKismetEditorUtilities::CreateBlueprint, Parent class default object and its variables are not what i set it to be, what am i doing wrong?

To give more information, i created a standalone plugin that is supposed to create a blueprint that inherits from a certain class, which works fine, it also should store the new blueprint in a specified folder on creation, which also works fine. But whenever i open the editor and place the blueprint in a level the variables that i set via c++ are usually null and require a reset to default to return to the variables i set originally.

It is almost as if my CDO is being overwritten or a default one is being created on top of mine.

Product Version: UE 4.13
Tags:
more ▼

asked Nov 08 '16 at 12:31 AM in C++ Programming

avatar image

KyleTimeFireVr
21 2 2 2

avatar image KyleTimeFireVr Nov 09 '16 at 06:12 PM

How do someone edit a Class Default Object? Can someone please tell me.

avatar image KyleTimeFireVr Nov 11 '16 at 06:50 PM

Staff Member please

avatar image kamrann Nov 13 '16 at 02:40 PM

Show some code from where you create the blueprint and attempt to set the defaults. Without doing so what kind of answer are you hoping to get?

avatar image KyleTimeFireVr Nov 14 '16 at 08:12 PM

to be honest i found an answer to what the problem is and to elaborate on it when a blueprint is created and it inherits from a class, the default object such as a static mesh component(root component) of the blueprint will represent what ever the default of the class is set to in its constructor. So if it is null in the constructor it it will be null in editor

avatar image KyleTimeFireVr Nov 14 '16 at 08:26 PM
 if (ClassToSpawnFrom != nullptr)
     {
         if (ensure(Package))
         {
             UObject* Default = SpawnerClass->GetDefaultObject();
 
             if (Default)
             {
                 UProperty* Property = FindField<UProperty>(Default->GetClass(), "ClassToSpawn");
 
                 APickupableSpawner* PickupableSpawner = NewObject<APickupableSpawner>();
 
                 UObject* Object = Cast<UObject>(PickupableSpawner);
 
                 FPropertyChangedEvent ClassPropertyEvent(Property);
 
                 APickupableSpawner* NewSpawnerArchetype = Cast<APickupableSpawner>(Default);
 
                 NewSpawnerArchetype->ClassToSpawn = ClassToSpawnFrom;
 
                 Default->PostEditChangeProperty(ClassPropertyEvent);
                 
                 UObject* ObjToTest = ClassToSpawnFrom->GetDefaultObject();
                 
                 AActor* Actor = Cast<AActor>(ObjToTest);
                 
                 UStaticMeshComponent* StaticMeshComp = Cast<UStaticMeshComponent>(Actor->GetRootComponent());
                 
                 NewSpawnerArchetype->OriginalStaticMeshComponent->StaticMesh = StaticMeshComp->StaticMesh; 
                 UObject* DefaultObject = Default;
 
                 const FString FileName = Default->GetName();
                 
                 const TCHAR* ConfigName = *FileName;
                 
                 FConfigCacheIni Config(EConfigCacheType::Temporary);
                 
                 FConfigFile& NewFile = Config.Add(ConfigName, FConfigFile());
 
                 Default->SaveConfig();
                 
                 if (UBlueprint* NewBP = FKismetEditorUtilities::CreateBlueprint(SpawnerClass, Package, NewAssetName, BPTYPE_Normal, UBlueprint::StaticClass(), UBlueprintGeneratedClass::StaticClass()))
                 {
                     FAssetEditorManager::Get().OpenEditorForAsset(NewBP);
                 
                     AssetRegistryModule.Get().AssetCreated(NewBP);
                 
                     Package->MarkPackageDirty();
                 }    
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question