Skip to content

Instantly share code, notes, and snippets.

View rbreve's full-sized avatar

Roberto Brevé rbreve

  • Finland
View GitHub Profile
@rbreve
rbreve / floating.m
Created November 10, 2016 22:09
Floating view inside UIScrollView
CGPoint currentOffset;
//Save the initial scrollview offset when adding floating view on the UIScrollView
currentOffset = scrollView.contentOffset;
- (void) scrollViewDidScroll:(UIScrollView *)scrollView{
CGRect frame = self.floatingView.frame;
frame.origin.x -= (currentOffset.x - scrollView.contentOffset.x);
frame.origin.y -= (currentOffset.y - scrollView.contentOffset.y);
@rbreve
rbreve / stickyheader.m
Created November 10, 2016 00:42
Floating Header UICollectionView Objective C
- (void)viewDidLoad {
//add this on your viewDidLoad
UICollectionViewFlowLayout *flow = (UICollectionViewFlowLayout *)self.collectionViewLayout;
flow.sectionHeadersPinToVisibleBounds = YES;
}
[{
"category_name": "Birthday",
"slug": "birthday"
}, {
"category_name": "Good Luck",
"slug": "goodluck"
}]
@rbreve
rbreve / tapdetect.cs
Created April 7, 2016 00:23
One Tap Detect Unity3D
foreach (Touch touch in Input.touches) {
if( touch.phase == TouchPhase.Ended ){
if(touch.tapCount == 1){
Debug.Log("Tap");
}
}
}
@rbreve
rbreve / CameraShake.cs
Created July 3, 2015 21:06
Simple camera shake script for Unity3d
using UnityEngine;
using System.Collections;
public class CameraShake : MonoBehaviour {
Camera cam;
public float shakeTime=0.2f;
float timeStop=0;
float shakeAmount=0.3f;
Vector3 originPosition;
@rbreve
rbreve / gist:3cfedda4d53a98317ba0
Last active August 29, 2015 14:18
Geek Honduras FAQ
Geek Honduras FAQ
¿Cual es el mejor proveedor de Internet?
Depende de la zona.
1.Claro
2.Cable Color
3.Amnet
@rbreve
rbreve / flip.cs
Last active August 29, 2015 14:14
Flip gameObject vertically Unity3D
void turnAround(){
Vector3 targetAngles = gameObject.transform.eulerAngles + 180f * Vector3.up;
gameObject.transform.eulerAngles = targetAngles;
}
@rbreve
rbreve / once.cs
Created October 8, 2014 03:34
Unity3D animator play once
public IEnumerator PlayOneShot ( string paramName )
{
anim.SetBool( paramName, true );
yield return new WaitForSeconds (anim.GetCurrentAnimatorStateInfo(0).length/2);
anim.SetBool( paramName, false );
}
// Use this for initialization
@rbreve
rbreve / sphereGameobject.cs
Last active August 29, 2015 14:06
Placing objects around a sphere in Unity3D
// sphere radius
float r= 5f;
Vector3 randomPosition = Random.onUnitSphere*r;
GameObject o = Instantiate(item, randomPosition, Quaternion.identity ) as GameObject;
Vector3 up = randomPosition;
Vector3 LookAt = Vector3.Cross(up, -transform.right) + up;
o.transform.LookAt(LookAt, up);
@rbreve
rbreve / gist:3f244574d7ab0e558d2d
Created September 4, 2014 20:24
Detect one tap in Unity3d
if(Input.touchCount == 1){
Touch touch = Input.GetTouch(0);
if(touch.phase == TouchPhase.Ended){
handleTouch(touch.position);
}
}