#define FUNC_DECLARE_DELEGATE( DelegateName, ... ) \
typedef TBaseDelegate<__VA_ARGS__> DelegateName;
// 이것이 delegate 생성기, 함수 등을 bind 할 수 있다
#define DECLARE_DELEGATE_RetVal( ReturnValueType, DelegateName ) FUNC_DECLARE_DELEGATE( DelegateName, ReturnValueType )
/*예로
아래 구문 중 이런 구문이 있다
static TAttribute Create( typename FGetter::FStaticDelegate::FFuncPtr InFuncPtr )
{
const bool bExplicitConstructor = true;
return TAttribute( FGetter::CreateStatic( InFuncPtr ), bExplicitConstructor ); //이 것이 델리게이트에 InFuncPtr 함수를 바인딩 하면서 생성 하는 과정
}
FGetter 는 아래 정의된 델리게이트인데 , 델리게이트 FGetter 를 통해서 CreateStatic 함수로 InFuncPtr이라는 수를 바인딩해서 만든 델리게이트를 리턴해
TAttribute 를 생성한다
*/
//예를 들어 TAttribute<bool> 해주면 bool 이라는 변수 타입을 갖는 변수가 하나 생성 되고,
//또한 bool 변수에 대해 처리하고자 하는 바인딩 함수를 걸 수 있다
/**
* Attribute object
*/
template< typename ObjectType >
class TAttribute
{
public:
/**
* Attribute 'getter' delegate
*
* ObjectType GetValue() const
*
* @return The attribute's value
*/
DECLARE_DELEGATE_RetVal( ObjectType, FGetter );
/** Default constructor. */
TAttribute()
: Value() // NOTE: Potentially uninitialized for atomics!!
, bIsSet(false)
, Getter()
{ }
/**
* Construct implicitly from an initial value
*
* @param InInitialValue The value for this attribute
*/
template< typename OtherType >
TAttribute( const OtherType& InInitialValue )
: Value( InInitialValue )
, bIsSet(true)
, Getter()
{ }
/**
* Static: Creates an attribute that's pre-bound to the specified 'getter' delegate
*
* @param InGetter Delegate to bind
*/
static TAttribute Create( const FGetter& InGetter )
{
const bool bExplicitConstructor = true;
return TAttribute( InGetter, bExplicitConstructor );
}
/**
* Creates an attribute by binding an arbitrary function that will be called to generate this attribute's value on demand.
* After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound
* function will always be called to generate the value.
*
* @param InFuncPtr Member function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.
*/
static TAttribute Create( typename FGetter::FStaticDelegate::FFuncPtr InFuncPtr )
{
//이 것이 델리게이트에 InFuncPtr 함수를 바인딩 하면서 생성 하는 과정
const bool bExplicitConstructor = true;
return TAttribute( FGetter::CreateStatic( InFuncPtr ), bExplicitConstructor );
}
/**
* Sets the attribute's value
*
* @param InNewValue The value to set the attribute to
*/
template< typename OtherType >
void Set( const OtherType& InNewValue )
{
Getter.Unbind();
Value = InNewValue;
bIsSet = true;
}
/** Was this TAttribute ever assigned? */
bool IsSet() const
{
return bIsSet;
}
/**
* Binds an arbitrary function that will be called to generate this attribute's value on demand.
* After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound
* function will always be called to generate the value.
*
* @param InUserObject Instance of the class that contains the member function you want to bind.
* @param InFunctionName Member function name to bind.
*/
template< class SourceType >
void BindUFunction( SourceType* InUserObject, const FName& InFunctionName )
{
bIsSet = true;
Getter.BindUFunction(InUserObject, InFunctionName);
}
/**
* Creates an attribute by binding an arbitrary function that will be called to generate this attribute's value on demand.
* After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound
* function will always be called to generate the value.
*
* @param InUserObject Instance of the class that contains the member function you want to bind.
* @param InFunctionName Member function name to bind.
*/
template< class SourceType >
static TAttribute< ObjectType > Create(SourceType* InUserObject, const FName& InFunctionName)
{
TAttribute< ObjectType > Attrib;
Attrib.BindUFunction<SourceType>(InUserObject, InFunctionName);
return Attrib;
}
........
중략
........
/**
* Is this attribute identical to another TAttribute.
*
* @param InOther The other attribute to compare with.
* @return true if the attributes are identical, false otherwise.
*/
bool IdenticalTo(const TAttribute& InOther) const
{
const bool bIsBound = IsBound();
if ( bIsBound == InOther.IsBound() )
{
if ( bIsBound )
{
return Getter.GetHandle() == InOther.Getter.GetHandle();
}
else
{
return Value == InOther.Value;
}
}
return false;
}
private:
/** Special explicit constructor for TAttribute::Create() */
TAttribute( const FGetter& InGetter, bool bExplicitConstructor )
: Value()
, bIsSet( true )
, Getter(InGetter)
{ }
// We declare ourselves as a friend (templated using OtherType) so we can access members as needed
template< class OtherType > friend class TAttribute;
/** Current value. Mutable so that we can cache the value locally when using a bound Getter (allows const ref return value.) */
mutable ObjectType Value; //이건 이전에 이전에 지정한 타입에 대한 변수이고
/** true when this attribute was explicitly set by a consumer, false when the attribute's value is set to the default*/
bool bIsSet;
/** Bound member function for this attribute (may be NULL if no function is bound.) When set, all attempts
to read the attribute's value will instead call this delegate to generate the value. */
/** Our attribute's 'getter' delegate */
FGetter Getter; //그래서 이게 delegate 가 됨
};
----------------------------------------------------------------------------------------
/**
* Use this macro to add a attribute to the declaration of your widget.
* An attribute can be a value or a function.
*/
#define SLATE_ATTRIBUTE( AttrType, AttrName ) \
TAttribute< AttrType > _##AttrName; \
WidgetArgsType& AttrName( const TAttribute< AttrType >& InAttribute ) \
{ \
_##AttrName = InAttribute; \
return this->Me(); \
} \
\
......
//some example..
SLATE_ATTRIBUTE( FText, ToolTipText )
SLATE_ATTRIBUTE( TOptional<EMouseCursor::Type>, Cursor )
SLATE_ATTRIBUTE( bool, IsEnabled )
SLATE_ATTRIBUTE( EVisibility, Visibility )
SLATE_ATTRIBUTE( TOptional<FSlateRenderTransform>, RenderTransform )
SLATE_ATTRIBUTE( FVector2D, RenderTransformPivot )
Öhm, this should work the same way, but i'm not sure if Epic changed something in the 4.6.1 update. There are a few things to check:
Are you sure you spelled it correctly?
Would you mind trying to press "Compile" in the upper left corner first?
Does this also happen in a complete new project?
Can you show me your Blueprint (:?
Can you make sure that you have "Context sensitive" marked at the upper right corner of the contest menu that opens when you rightclick?
Can you try calling the event by only rightclicking and searching it instead of dragging of the pin.
https://www.dropbox.com/s/usido8i2gxdcyuk/Screenshot%202015-01-05%2001.16.12.png?dl=0
Attached screenshot shows a custom event I made and what happens when i try to search for the function call. It was compiled before searching. I started off with a blank c++ template and then created a new empty level. Please let me know if there is any other information you require.
I'm not at my pc right now, but would you mind disabling "Call in Editor" at the Event options at the lower left of the BP and try it again?
in level BP right clic and put this ===>