#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 )
The sub folders and pngs are in my streaming assets folder in unity. When it gets exported as a google android project, they are in the android project's assets folder.
Is there some (alternative) way to list up all .png files in my sub folder ?
Hmm, is there a reason you don't use Application.streamingAssetsPath like suggested on this page?
Also keep in mind, like mentioned on the doc page, on android the files are not in a folder, they are within a jar file. So GetFiles won't work on this path since it's not an actual path. If you want to "browse" your folder you need a zip-library to open the jar manually.
GetFiles works perfectly well on real folders as long as you have file permission.
I actually have tried using: string streamingAssetsPathAndroid = Application.streamingAssetsPath;
Which pretty much results in the same path string and the same folder not found error for me.
I may have to consider that it may not be possible to use Directory.GetFiles on a unity game exported to google android project...
Bunny's right you can't scan the directory because it is in a ZIP file. You can use a ZIP library to examine the JAR and get files from it.
I use this: http://www.icsharpcode.net/opensource/sharpziplib/ for a lot of stuff.