Skip to content

Instantly share code, notes, and snippets.

Avatar
🌍
https://ninevastudios.com/

Taras Leskiv TarasOsiris

🌍
https://ninevastudios.com/
View GitHub Profile
@TarasOsiris
TarasOsiris / EncryptedXmlSerializer.cs
Last active Feb 7, 2021
Save encrypted XML Files in Unity3D. Tested on Android, iOS, Windows standalone, Mac.
View EncryptedXmlSerializer.cs
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 Feb 26, 2014
Put this script on game object with UIDragScrollView to get scale and alpha highlighting effect. Might be not very efficient but it works ok.
View UiHighlightCenteredItem.cs
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 Aug 29, 2015
Generic method to create .asset files. Taken from here http://www.jacobpennock.com/Blog/?page_id=715 and modified a bit.
View CustomAssetUtility.cs
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
View .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 May 9, 2018
Unity3d method to retrieve device ANDROID_ID constant.
View AndroidIdRetriever.cs
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 Aug 29, 2015
Playmaker action to set color of the SmoothMoves.Sprite.
View SmoothMoves_SetSpriteColor.cs
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 Jun 20, 2014
Unity3D PlayerPrefs wrapper to provide saving boolean values.
View CustomPlayerPrefs.cs
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 Jun 24, 2014
Set Android Texture Compression uTomate Action
View UTSetAndroidBuildSubtarget.cs
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 Nov 20, 2018
Singleton MonoBehavior for Unity3d
View MonoSingleton.cs
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 Aug 29, 2015
Collection extension methods
View ListUtils.cs
using System.Collections.Generic;
using System;
namespace TarasOsirisGists
{
public static class ListUtils
{
private static Random _rnd;
/// <summary>