Skip to content

Instantly share code, notes, and snippets.

View TarasOsiris's full-sized avatar
🌍
https://ninevastudios.com/

Taras Leskiv TarasOsiris

🌍
https://ninevastudios.com/
View GitHub Profile
using UnityEngine;
public static class CameraExtensions {
public static void LayerCullingShow(this Camera cam, int layerMask) {
cam.cullingMask |= layerMask;
}
public static void LayerCullingShow(this Camera cam, string layer) {
LayerCullingShow(cam, 1 << LayerMask.NameToLayer(layer));
@TarasOsiris
TarasOsiris / AndroidIdRetriever.cs
Last active November 22, 2023 13:31
Unity3d method to retrieve device ANDROID_ID constant.
using UnityEngine;
public static class AndroidIdRetriever
{
public static string Retrieve()
{
AndroidJavaClass clsUnity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject objActivity = clsUnity.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject objResolver = objActivity.Call<AndroidJavaObject>("getContentResolver");
AndroidJavaClass clsSecure = new AndroidJavaClass("android.provider.Settings$Secure");
using UnityEngine;
public class AlarmClock : MonoBehaviour
{
const string ACTION_SET_ALARM = "android.intent.action.SET_ALARM";
const string EXTRA_HOUR = "android.intent.extra.alarm.HOUR";
const string EXTRA_MINUTES = "android.intent.extra.alarm.MINUTES";
const string EXTRA_MESSAGE = "android.intent.extra.alarm.MESSAGE";
public void OnClick()
@TarasOsiris
TarasOsiris / EncryptedXmlSerializer.cs
Last active October 16, 2023 15:31
Save encrypted XML Files in Unity3D. Tested on Android, iOS, Windows standalone, Mac.
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Xml.Serialization;
using UnityEngine;
namespace Com.Nravo.FlipTheBoard.PersistantStorage
{
#if UNITY_ANDROID
using UnityEngine;
using System;
public static class AndroidNativePicker
{
public delegate void OnDatePicked(int year,int month,int day);
public delegate void OnTimePicked(int hourOfDay, int minute);
public static void ShowDatePicker(OnDatePicked callback)
@TarasOsiris
TarasOsiris / CustomPlayerPrefs.cs
Created June 20, 2014 09:13
Unity3D PlayerPrefs wrapper to provide saving boolean values.
using UnityEngine;
/// <summary>
/// PlayerPrefs wrapper to provide saving boolean values.
/// </summary>
public static class CustomPlayerPrefs
{
private const int StorageFalse = 0;
private const int StorageTrue = 1;
@TarasOsiris
TarasOsiris / BetterDefines.cs
Last active April 21, 2023 20:22 — forked from Borod4r/BetterDefines.cs
Better Defines for Unity3D
using System;
using System.Collections.Generic;
using System.Linq;
using BetterDefines.Editor.Entity;
using UnityEditor;
namespace BetterDefines.Editor
{
public static class BetterDefinesUtils
{
@TarasOsiris
TarasOsiris / FlowMap.shader
Last active April 20, 2023 07:36
Flow Map Shader for Unity3D. Used with Sprites.
Shader "Custom/Flow Map"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
// Flow
_FlowMap ("Flow Map", 2D) = "white" {}
_FlowSpeed ("Flow Speed", float) = 0.05
@TarasOsiris
TarasOsiris / ShowToastUnityAndroid.cs
Created April 15, 2016 12:52
Shows toast on Android
public static void ShowToast(string text)
{
if (Application.platform == RuntimePlatform.Android)
{
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
activity.Call("runOnUiThread", new AndroidJavaRunnable(
()=>
{
@TarasOsiris
TarasOsiris / DumpEditorTextures.cs
Last active February 15, 2023 10:07
Dump all Unity3d Editor GUI skin textures as images
using UnityEngine;
using System.IO;
using UnityEditor;
public static class DumpEditorTextures
{
const string AssetsFolder = "Assets";
const string TexturesDestFolderNamePro = "TexturesPro";
const string TexturesDestFolderNameNormal = "TexturesNormal";
static readonly string TexturesDestPathPro = Path.Combine(AssetsFolder, TexturesDestFolderNamePro);