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"

Expose c++ class to blueprint, where is my error?

Hello everyone,

I'm trying to expose the following to blueprint. It compiles, but when I right click on my class, the "Create blueprint class based on ..." is not available. What do I do wrong? Thank you!

My .h

 #pragma once
 
 #include "Object.h"
 #include "FileHelpers.h"
 #include "FileLoaderReader.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class VROPHOBIAV3_API UFileLoaderReader : public UObject
 {
     GENERATED_BODY()
     
 public:
     static bool VerifyOrCreateDirectory(const FString& TestDir);
 
     UFUNCTION(BlueprintCallable, Category = "Load/Save Text File")
         bool WriteToFile(FString Path, FString FileName, FString TextToSave, bool AllowOverwriting);
 
     UFUNCTION(BlueprintCallable, Category = "Load/Save Text File")
         bool ReadFromFile(FString PathToFile, FString FileName, FString& Result);
     
     
 };
 

And the CPP

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #include "VRoPhobiaV3.h"
 #include "FileLoaderReader.h"
 
 
 //If this function cannot find or create the directory, returns false.
 bool UFileLoaderReader::VerifyOrCreateDirectory(const FString& TestDir)
 {
     // Every function call, unless the function is inline, adds a small
     // overhead which we can avoid by creating a local variable like so.
     // But beware of making every function inline!
     IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
 
     // Directory Exists?
     if (!PlatformFile.DirectoryExists(*TestDir))
     {
         PlatformFile.CreateDirectory(*TestDir);
 
         if (!PlatformFile.DirectoryExists(*TestDir))
         {
             return false;
             //~~~~~~~~~~~~~~
         }
     }
     return true;
 }
 
 bool UFileLoaderReader::WriteToFile(FString Path, FString FileName, FString TextToSave, bool AllowOverwriting)
 {
     VerifyOrCreateDirectory(Path);
 
     IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
 
     // CreateDirectoryTree returns true if the destination
     // directory existed prior to call or has been created
     // during the call.
     if (PlatformFile.CreateDirectoryTree(*Path))
     {
         // Get absolute file path
         FString AbsoluteFilePath = Path + "/" + FileName;
 
         // Allow overwriting or file doesn't already exist
         if (AllowOverwriting || !PlatformFile.FileExists(*AbsoluteFilePath))
         {
             FFileHelper::SaveStringToFile(TextToSave, *AbsoluteFilePath);
             return true;
         }
     }
     return false;
 }
 
 bool UFileLoaderReader::ReadFromFile(FString PathToFile, FString FileName, FString& Result)
 {
     IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
 
     // CreateDirectoryTree returns true if the destination
     // directory existed prior to call or has been created
     // during the call.
     if (PlatformFile.CreateDirectoryTree(*PathToFile))
     {
         // Get absolute file path
         FString AbsoluteFilePath = PathToFile + "/" + FileName;
 
         // Allow overwriting or file doesn't already exist
         if (PlatformFile.FileExists(*AbsoluteFilePath))
         {
             FFileHelper::LoadFileToString(Result, *AbsoluteFilePath);
             return true;
         }
     }
     return false;
 }

Product Version: UE 4.10
Tags:
more ▼

asked May 09 '16 at 02:05 PM in C++ Programming

avatar image

dexluce
1 1 3 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I removed VROPHOBIAV3_API, didn't do much good.

But adding "Blueprintable" to UCLASS() is working :)

thank you!

more ▼

answered May 09 '16 at 02:22 PM

avatar image

dexluce
1 1 3 6

avatar image roomon1 May 09 '16 at 07:11 PM

Sounds like the exact right solution -- According to the documentation on Class Specifiers, the Blueprintable specifier "Exposes this class as an acceptable base class for creating Blueprints." Without it you won't be able to create blueprints based on your class.

As a side note, the VROPHOBIAV3_API isn't actually a second class name in this case. It is instead a macro used by the build system. You can find more information about the macro here or the build system here.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

It looks like you have 2 class names. VROPHOBIAV3_API should be removed.

more ▼

answered May 09 '16 at 02:18 PM

avatar image

mikepurvis
2.5k 102 67 262

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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