Skip to content

Instantly share code, notes, and snippets.

View gashtio's full-sized avatar

Nikola Vasilev gashtio

View GitHub Profile
@gashtio
gashtio / d3d11device_vtableptrs.cpp
Created October 29, 2013 13:10
Getting the offsets of the IUnknown virtual functions for ID3D11Device.
#include <iostream>
#include <d3d11.h>
#pragma comment(lib, "d3d11.lib")
int main()
{
D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0 };
ID3D11Device* device = nullptr;
ID3D11DeviceContext* context = nullptr;
@gashtio
gashtio / facebook_makebutton.js
Created February 22, 2013 08:47
Displaying a button with a varying background image, depending on whether the user is logged in (in the Unity3D Facebook integration with Coherent UI sample)
var appID = '344764665598630';
var appURL = 'http://www.coherent-labs.com/sample.html';
if (window.location.hash.length == 0)
{
// Not logged in
$(function () {
var button = $('<div id="fbButton" class="fbLogoDisabled"></div>');
button.click(function () {
@gashtio
gashtio / facebook_portrait.js
Created February 22, 2013 08:42
Setting of portrait upon successful login in the Unity3D Facebook integration with Coherent UI sample
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.authResponse) {
// user has auth'd your app and is logged into Facebook
// request users' first name and profile picture
FB.api('/me?fields=picture,first_name', function(me){
SetPortrait(me);
userID = me.id;
});
}
})
@gashtio
gashtio / facebook.js
Created February 22, 2013 08:34
The whole JavaScript file for the Unity3D Facebook integration with Coherent UI sample
var appID = '344764665598630';
var appURL = 'http://www.coherent-labs.com/sample.html';
var userID;
var userToken;
function SetPortrait(fbAvatar) {
var url = fbAvatar.picture.data.url;
$('#fbButton').css("background-image", "url(" + url + ")");
}
@gashtio
gashtio / SignalReceiver.cs
Created February 21, 2013 21:36
Component that handles signals received upon mech death
using UnityEngine;
using System.Collections;
using Coherent.UI;
using Coherent.UI.Binding;
using System.IO;
public class SignalReceiver : MonoBehaviour {
private CoherentUIView m_View;
private string m_LocalAppURL;
@gashtio
gashtio / achievement.css
Created February 21, 2013 20:37
CSS for the achievement page
.achievementPopupBottomPlacer
{
position: fixed;
width: 100%;
bottom: 48px;
}
.achievementPopup
{
width: 425px;
@gashtio
gashtio / achievement.html
Created February 21, 2013 20:35
HTML code for displaying an in-game popup
<html>
<head>
<script type='text/javascript' src="js/jquery-1.9.1.min.js"></script>
<script type='text/javascript' src="js/jquery-ui-1.10.1.custom.min.js"></script>
<script type='text/javascript' src="js/coherent.js"></script>
<link rel="stylesheet" href="css/achievement.css" />
</head>
<body>
@gashtio
gashtio / MinigameDoorOpener.cs
Created February 20, 2013 08:53
A helper script that adds a handler for the "OpenDoor" message in the Coherent UI View Listener, received from JavaScript.
using UnityEngine;
using System.Collections;
public class MinigameDoorOpener : MonoBehaviour {
private CoherentUIView m_View;
// Use this for initialization
void Start () {
m_View = GetComponent<CoherentUIView>();
@gashtio
gashtio / TriggerOnMouseOrJoystick.js
Created February 20, 2013 08:50
Modified TriggerOnMouseOrJoystick.js Unity3D script that allows toggling its functionality
...
private var allowInput : boolean = true;
...
function Update () {
if (Input.GetKeyDown(KeyCode.Space))
{
allowInput = !allowInput;
}
@gashtio
gashtio / clip.html
Created February 1, 2013 14:01
Clipping an image to a circle using border-radius CSS property
<img src="http://profile.ak.fbcdn.net/hprofile-ak-snc4/276311_100002617687873_1118195351_n.jpg"
style="width: 100px; height:100px; -webkit-border-radius:52px;">