Skip to content

Instantly share code, notes, and snippets.

View SiarheiPilat's full-sized avatar
:octocat:
Working from home

suasor SiarheiPilat

:octocat:
Working from home
  • Suasor AB
  • Malmö, Sweden
View GitHub Profile
@SiarheiPilat
SiarheiPilat / FindCustomScriptsEditor.cs
Last active January 23, 2023 03:56
Find all custom scripts in the hierarchy of the current scene, show as a list of buttons, user can ping the object by clicking a button. Omits native Unity components.
using UnityEngine;
using UnityEditor;
using System;
namespace Suasor
{
public class FindCustomScriptsEditor : EditorWindow
{
Vector2 scrollPosition;
public string[] Strings = new string[4] {"BreakableHelper", "ObjectColor", "StickerController", "Obi" }; // REPLACE THIS WITH LIST EDITABLE
@SiarheiPilat
SiarheiPilat / post-build-push-ipa-appstore.bash
Created June 3, 2022 02:29
Automates cloud build upload to iTunes Connect
#!/bin/bash
echo "Uploading IPA to Appstore Connect..."
# Taken from this great thread: https://forum.unity.com/threads/path-to-the-final-ipa-file.754331/
#Path is "/BUILD_PATH/<ORG_ID>.<PROJECT_ID>.<BUILD_TARGET_ID>/.build/last/<BUILD_TARGET_ID>/build.ipa"
path="$WORKSPACE/.build/last/$TARGET_NAME/build.ipa"
if xcrun altool --upload-app --type ios -f $path -u $ITUNES_USERNAME -p $ITUNES_PASSWORD ; then
echo "Upload IPA to Appstore Connect finished with success"
else
@SiarheiPilat
SiarheiPilat / ExcemptFromEncryption.cs
Last active December 12, 2023 20:58
Automates encryption compliance setting for iOS builds.
#if UNITY_IOS
using UnityEngine;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor;
using UnityEditor.iOS.Xcode;
using System.IO;
public class ExcemptFromEncryption : IPostprocessBuildWithReport // Will execute after XCode project is built
/***************************************************************/
/********** Simple target orientation camera script. ***********/
/*** You can change parameters, such as rotation/zoom speed. ***/
/***************************************************************/
// Original: https://github.com/steaklive/Orbit-Camera-for-Unity-Demos
using UnityEngine;
using System.Collections;
@SiarheiPilat
SiarheiPilat / CoolButton.cs
Last active August 22, 2023 21:29
Replacement for a TextMeshPRO button that will automatically change button text.
using UnityEngine;
using UnityEngine.UI;
using TMPro;
/// Original: https://gist.github.com/SiarheiPilat/e4fa93c97d31d8d0e2d18f34e0e2abe9
/// Author: Siarhei Pilat
/// Date: 29-05-2022
/// License: MIT
public class CoolButton : MonoBehaviour
using UnityEditor;
using UnityEngine;
public class ReadWriteModelPostprocessor : AssetPostprocessor
{
void OnPreprocessModel()
{
Debug.Log("Setting Read/Write permission automatically... Delete this script if this is not intended.");
ModelImporter modelImporter = assetImporter as ModelImporter;
modelImporter.isReadable = true;
// taken from https://forum.unity.com/threads/shortcut-to-close-editor-window-close-tab.1232121/
using UnityEditor;
using UnityEngine;
public class EditorCloseWindowTab : Editor
{
[MenuItem("Shortcuts/Close Window Tab")]
static void CloseTab()
{
// taken from https://answers.unity.com/questions/460530/forcing-a-guid-to-regeneraterefresh.html
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
namespace UnityGuidRegenerator {
public class UnityGuidRegeneratorMenu {
[MenuItem("Tools/Regenerate asset GUIDs")]
@SiarheiPilat
SiarheiPilat / AutoSave.cs
Last active September 5, 2022 00:36
future release of autosaver sua
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
namespace Suasor
{
// TODO:
// editor settings window
// rate button
@SiarheiPilat
SiarheiPilat / new pre commit
Last active March 15, 2023 18:32
Automatically increment project version on each commit to main (on pre commit)
#!/bin/sh
# new pre commit
# get bundle version
bundle_ver=`cat ./ProjectSettings/ProjectSettings.asset | grep bundleVersion | cut -d ' ' -f 4`
# explanation:
# cat - concatenate the content of multiple files
# cat [option] [file]
# cut command is a fast way to extract parts of lines of text files