Skip to content

Instantly share code, notes, and snippets.

@yasirkula
yasirkula / ScrollViewFocusFunctions.cs
Created October 23, 2021 10:09
Focus/center Scroll View to the specified point/item in Unity
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public static class ScrollViewFocusFunctions
{
public static Vector2 CalculateFocusedScrollPosition( this ScrollRect scrollView, Vector2 focusPoint )
{
Vector2 contentSize = scrollView.content.rect.size;
Vector2 viewportSize = ( (RectTransform) scrollView.content.parent ).rect.size;
@Troyciv
Troyciv / button.html
Last active June 11, 2024 11:58
Anki: a simple hide/show button on card
<button class="button" type="button" onclick="
if
(document.getElementById('ID') .style.display=='none')
{document.getElementById('ID') .style.display=''}
else
{document.getElementById('ID') .style.display='none'}">
label of the button
</button>
<div id="ID" style="display:none">
@skabber
skabber / exportOptions.plist
Last active September 11, 2025 20:26
Export Options Plist Example
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>XXXXXXXXXX</string>
<key>uploadBitcode</key>
<true/>
@christianascone
christianascone / archiveXcodeProjectWithPods.sh
Last active March 16, 2022 02:59
Archive a project with Cocoapods dependencies
#!/bin/bash
PROJECT_NAME="$(ls -d *.xcworkspace* | cut -d'.' -f1)"
# REF: https://bitbar.com/tipstricks-how-to-archive-and-export-ipa-from-script/
# Clean project
echo "#### CLEAN ####"
xcodebuild clean -workspace "${PROJECT_NAME}".xcworkspace -configuration Release -scheme "${PROJECT_NAME}"
# Archive
echo "#### ARCHIVE ####"
xcodebuild archive -workspace "${PROJECT_NAME}".xcworkspace -configuration Release -scheme "${PROJECT_NAME}" -archivePath "${PROJECT_NAME}".xcarchive
# Export ipa
@marcelschmidtdev
marcelschmidtdev / ScrollToSelected.cs
Created March 30, 2016 00:42
Autoscroll Scrollrect for Unity
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
[RequireComponent(typeof(ScrollRect))]
public class ScrollToSelected : MonoBehaviour
{
public float scrollSpeed = 10f;
@cocoaNib
cocoaNib / exportOptionsAdHoc.plist
Last active July 3, 2025 09:38
Xcode build with exportOptionsPlist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>ad-hoc</string>
</dict>
</plist>
@onevcat
onevcat / MonoSingleton.cs
Created July 18, 2013 00:37
Mono singleton Class. Extend this class to make singleton component.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Mono singleton Class. Extend this class to make singleton component.
/// Example:
/// <code>
/// public class Foo : MonoSingleton<Foo>
/// </code>. To get the instance of Foo class, use <code>Foo.instance</code>
@bzgeb
bzgeb / TriggerContainerEditor.cs
Created September 28, 2012 14:52
Example Drag & Drop area in a custom inspector for the Unity editor
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor (typeof(TriggerContainer))]
public class TriggerContainerEditor : Editor
{
private SerializedObject obj;