Skip to content

Instantly share code, notes, and snippets.

/* inside activity class */
private val launcher = registerForActivityResult(OpenDocumentTreePersistent()) { uri: Uri? ->
if (uri != null)
contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
/* ... */
}
@Kurante2801
Kurante2801 / AnimationCurveBaker.cs
Last active February 16, 2023 20:27
Implement Unity's AnimationCurve in Java by precalculating the values a curve can have in Unity and then pasting the values in Java
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using UnityEngine;
[ExecuteAlways]
public class AnimationCurveBaker : MonoBehaviour
{
public AnimationCurve curve;
@Kurante2801
Kurante2801 / AndroidManifest.xml
Last active January 11, 2023 22:41 — forked from HassakuTb/AndroidManifest.xml
Reimplementation of UnityPlayerActivity with AppCompatActivity and Kotlin
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kurante.uactivity"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light">
<activity android:name=".UnityPlayerActivity"
@Kurante2801
Kurante2801 / TabMenu.cs
Created December 25, 2022 16:28
Tab Menu for Unity UI Builder
using UnityEngine.UIElements;
public class TabMenu : VisualElement
{
public new class UxmlFactory : UxmlFactory<TabMenu, UxmlTraits> { }
public new class UxmlTraits : VisualElement.UxmlTraits
{
UxmlBoolAttributeDescription m_canToggle = new() { name = "can-toggle", defaultValue = false };
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
@Kurante2801
Kurante2801 / vtf_compress.py
Last active January 24, 2024 16:20
VTF Compression script
# MAKE A BACKUP OF YOUR FILES BEFORE USING SCRIPT
# Requires VTFCmd.exe
import os, subprocess
from PIL import Image
from time import time
MAX_WIDTH = 1024
MAX_HEIGHT = 1024