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
@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
{
@TarasOsiris
TarasOsiris / UiHighlightCenteredItem.cs
Created February 26, 2014 09:54
Put this script on game object with UIDragScrollView to get scale and alpha highlighting effect. Might be not very efficient but it works ok.
using UnityEngine;
using System;
namespace Com.Nravo.NGUI {
[RequireComponent(typeof(UIDragScrollView))]
public class UiHighlightCenteredItem : MonoBehaviour {
// coefs to monitor
// zero means target is centered, 1 means target is max away
[Range(0.0f, 1.0f)] public float distanceFromCenterHorizontalCoef;
@TarasOsiris
TarasOsiris / CustomAssetUtility.cs
Last active August 29, 2015 13:56
Generic method to create .asset files. Taken from here http://www.jacobpennock.com/Blog/?page_id=715 and modified a bit.
using UnityEngine;
using UnityEditor;
using System.IO;
/// <summary>
/// Taken from here : http://www.jacobpennock.com/Blog/?page_id=715 and modified
/// </summary>
public static class CustomAssetUtility
{
public static void CreateAsset<T>() where T : ScriptableObject
@TarasOsiris
TarasOsiris / .gitignore
Last active August 29, 2015 13:56 — forked from zasadnyy/.gitignore
# =============== #
# Unity generated #
# =============== #
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
#Unity3D Generated File On Crash Reports
sysinfo.txt
@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");
@TarasOsiris
TarasOsiris / SmoothMoves_SetSpriteColor.cs
Last active August 29, 2015 13:58
Playmaker action to set color of the SmoothMoves.Sprite.
using HutongGames.PlayMaker;
using UnityEngine;
[ActionCategory("SmoothMoves")]
[Tooltip("Sets the sprite color of the Sprite")]
public class SmoothMoves_SetSpriteColor : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(SmoothMoves.Sprite))]
[Tooltip("Game Object to set the color on.")]
@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 / UTSetAndroidBuildSubtarget.cs
Created June 24, 2014 09:57
Set Android Texture Compression uTomate Action
using UnityEditor;
[UTActionInfoAttribute(actionCategory = "Build")]
[UTDoc(title = "Set Android Texture Compression", description = "Sets Android texture Compression.")]
[UTInspectorGroups(groups = new []{ "Player" })]
public class UTSetAndroidBuildSubtarget : UTAction
{
[UTDoc(description = "Android targets, only: The texture compression.")]
[UTInspectorHint(group = "Player", order = 4, required = true)]
@TarasOsiris
TarasOsiris / MonoSingleton.cs
Last active November 20, 2018 15:03
Singleton MonoBehavior for Unity3d
using JetBrains.Annotations;
using UnityEngine;
[PublicAPI]
public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
{
static T _instance;
public static T Instance
{
@TarasOsiris
TarasOsiris / ListUtils.cs
Last active August 29, 2015 14:04
Collection extension methods
using System.Collections.Generic;
using System;
namespace TarasOsirisGists
{
public static class ListUtils
{
private static Random _rnd;
/// <summary>