Skip to content

Instantly share code, notes, and snippets.

View rsaenzi's full-sized avatar
🏠
Working from home

Rigoberto Sáenz Imbacuán rsaenzi

🏠
Working from home
View GitHub Profile
@rsaenzi
rsaenzi / HierarchyHighlighter.cs
Created October 20, 2021 00:01
Script for unity to highlight a game object in the hierarchy
//
// HierarchyHighlighter.cs
//
// Created by Rigoberto Sáenz Imbacuán (https://linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
using System;
using System.Collections.Generic;
using System.Linq;
@rsaenzi
rsaenzi / CollisionSound.cs
Created September 11, 2021 03:53
Script for Unity to play a sound when a Collider 2D is touched by another Collider 2D
//
// CollisionSound.cs
//
// Created by Rigoberto Sáenz Imbacuán (https://linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@rsaenzi
rsaenzi / UICollectionViewLeftAlignmentFlowLayout.swift
Created March 5, 2021 03:14
UICollectionViewFlowLayout that aligns all the UICollectionViewCells to the top-left
//
// UICollectionViewLeftAlignmentFlowLayout.swift
//
// Created by Rigoberto Sáenz Imbacuán (https://www.linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
class UICollectionViewLeftAlignmentFlowLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
@rsaenzi
rsaenzi / OnTapButtonInsideCell.swift
Last active March 5, 2021 03:13
Swift code to detect touches for buttons placed inside a UITableViewCell or UICollectionViewCell
//
// OnTapButtonInsideCell.swift
//
// Created by Rigoberto Sáenz Imbacuán (https://www.linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
private func onTapButtonInsideCell(button: UIButton, event: UIEvent) {
guard let touches = event.touches(for: button), !touches.isEmpty else {
@rsaenzi
rsaenzi / DragAndDrop.cs
Last active May 5, 2024 17:40
Script for Unity to add Drag and Drop support for 2D/3D objects
//
// DragAndDrop.cs
//
// Created by Rigoberto Sáenz Imbacuán (https://linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@rsaenzi
rsaenzi / AudioPlayer.cs
Last active November 7, 2021 23:48
Script for Unity to play/stop sound fx and music
//
// AudioPlayer.cs
//
// Created by Rigoberto Sáenz Imbacuán (https://linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@rsaenzi
rsaenzi / LevelLoader.cs
Last active November 7, 2021 23:49
Script for Unity to load/unload levels
//
// LevelLoader.cs
//
// Created by Rigoberto Sáenz Imbacuán (https://linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@rsaenzi
rsaenzi / UINavigation.cs
Last active November 7, 2021 23:49
Script for Unity to load/unload UI screens
//
// UINavigation.cs
//
// Created by Rigoberto Sáenz Imbacuán (https://linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@rsaenzi
rsaenzi / CustomCell.swift
Last active March 12, 2020 04:14
Template for custom table cell loaded from a .xib file
//
// CustomCell.swift
//
// Created by Rigoberto Sáenz Imbacuán (https://www.linkedin.com/in/rsaenzi/)
// Copyright © 2019. All rights reserved.
//
// Notes:
// - Bind content to the ContentView in Interface Builder
// - Make the xib's file owner be this class
@rsaenzi
rsaenzi / Parallax.cs
Last active April 12, 2021 04:17
Script for Unity to implement Parallax effect for backgrounds on 2D games
//
// Parallax.cs
//
// Created by Rigoberto Sáenz Imbacuán (https://linkedin.com/in/rsaenzi/)
// Copyright © 2021. All rights reserved.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;