Skip to content

Instantly share code, notes, and snippets.

View Anruin's full-sized avatar
🏠
Working from home

Hackerman Me Anruin

🏠
Working from home
View GitHub Profile
@Anruin
Anruin / CMakeLists.txt
Last active July 14, 2021 04:38
Unreal Engine PowerIK Cross-Platform Build
cmake_minimum_required(VERSION 2.8.12)
project(PowerIK)
option(BUILD_ANDROID "Build for Android" OFF)
# Build using Unix. At Windows I used WSL.
if(BUILD_ANDROID)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 29) # API level
@Anruin
Anruin / UE4_GenerateMipmaps.cpp
Last active April 10, 2024 03:51
CPU code used to generate dynamic mipmaps for UE4 dynamic UTexture2D objects.
// Copyright 2021 Impossibility Labs Inc. https://github.com/ArtheonVR.
// Based on: https://answers.unrealengine.com/questions/607129/how-do-you-generate-mips-at-runtime.html
void FAsyncTaskDownloadTexture::GenerateMipmaps() const {
const int32 Width = Texture->GetSizeX();
const int32 Height = Texture->GetSizeY();
// Texture bytes.
TArray<uint8> TextureByteArray;
TextureByteArray.AddUninitialized(Texture->PlatformData->Mips[0].BulkData.GetElementCount());
@Anruin
Anruin / ue4_android_permission_wrapper.cpp
Last active June 18, 2021 21:12
UE4 Android Permission request wrapper macro
// Copyright 2021 Impossibility Labs Inc. https://github.com/ArtheonVR.
// Created by Egor Pristavka.
// Macro definition:
#if PLATFORM_ANDROID
#include "AndroidPermissionFunctionLibrary.h"
#include "AndroidPermissionCallbackProxy.h"
#define RUN_WITH_PERMISSION(perm, ...)\
LogF("AndroidPermission: Checking %s permission.", perm);\
if (!UAndroidPermissionFunctionLibrary::CheckPermission(perm)) {\
@Anruin
Anruin / UIDebounce.h
Last active July 12, 2021 08:15
UE4 UMG Debounce Macro
// Can be used on buttons to allow single click in some period of time, for example limit to few clicks per second.
#define DEBOUNCE(s, ...) \
static bool bActive; \
if (!bActive) { \
bActive = true; \
__VA_ARGS__; \
FTimerHandle DebounceTimerHandle; \
GetWorld()->GetTimerManager().SetTimer(DebounceTimerHandle, FTimerDelegate().CreateLambda([](){\
bActive = false; \