Tuesday, 13 January 2015

Deploy Unity 3D Project to Samsung Galaxy Tab

Install the drivers

Install the Samsung Kies software
It can be downloaded from http://www.samsung.com/ie/support/usefulsoftware/KIES/

Enable Developer Options on the Tablet

On the tablet
Go to Settings -> General -> Left hand panel, scroll down to About device.
In the About device main panel, scroll down to Build number and tap it 7 times.
Quit the settings application.
Go to Settings -> General -> Left hand panel, scroll down to Developer options.
Tab the Enable USB debugging checkbox

Configure the Build Settings

In Unity go to File -> Build Settings...
In the Platform panel click Android and then click the Switch Platform button
Click on Add Current to add your scene to the android package. If you have multiple scenes in the game, make sure to add them all and make sure that they are in the correct order

Build the Game and Deploy to the Tablet

Then in Unity do File -> Build and Run

The first time you perform a build and run, you should get a notification on the tablet to allow the application to get pushed to the tablet. Allow this. Pushing the game to the device might fail, if it does click Build and Run again in Unity. It should start the game on the tablet.

Wednesday, 10 December 2014

Disable Screen Auto Rotation on Unity3D

Disable screen auto-rotation in a game in Unity. 

Option 1


Create a script that disables auto rotate to portrait and sets the orientation to landscape.

using UnityEngine;

public class CameraScript : MonoBehaviour {

    void Start() {
        DisableAutoRotation ();
    }

    public void DisableAutoRotation() {
        Screen.autorotateToPortrait = false;
        Screen.autorotateToPortraitUpsideDown = false;
        Screen.orientation = ScreenOrientation.Landscape;
    }
}



Create a game object to attach the script to. This can be any game object. You could also attach the script to the main camera in the scene either. When the game is run on hand held devices, the autorotation will be disabled.

Option 2


Another solution to this problem is to change this setting when building the project. 
Go to 
File -> Build Settings...




Click on Player Settings...


Click on Resolution and Presentations panel in the inspector. This will then expand and present more options.




In the Resolution and Presentation panel there are options for configuring the orientation.
First select the default Orientation. This is the orientation that the game will start in. 
You can configure what orientations are allowed when the game is being run. To do this, check or uncheck the required boxes for "Allowed Orientations for Auto Rotation".



Monday, 13 October 2014

Setting up Minidlna on Linux Mint

Minidlna is useful for broadcasting media around your home network. Multimedia can be streamed from the minidlna server to different upnp enabled devices such as computers/smartphones/game consoles.

Install the Pre-requisites
sudo apt-get install software-properties-common python-software-properties


Add the repository to get minidlna
sudo add-apt-repository ppa:djart/mindlna


update the repo
sudo apt-get update


Install minidlna
sudo apt-get install minidlna


Change the configuration file
sudo vim /etc/minidlna.conf


Change the user in the file to whatever user you want to use
Comment out the media_dir
Add an Audio directory, Video directory, Pictures directory. Also add the location that the Log files will be kept and where the database file will be kept
media_dir=A,/home/myuser/Music
media_dir=P,/home/myuser/Pictures
media_dir=V,/home/myuser/Videos
db_dir=/home/myuser/Cache
log_dir=/home/myuser/Log

Change the name of the DLNA server
friendly_name=myServerName


Restart the minidlna server
sudo service minidlna restart


If you see this error, Cannot connect to server, make sure to reload the server with the new content,
minidlnad -R

Thursday, 12 June 2014

Allow Remote Connections to MySQL Database on Raspberry Pi

This article shows how to set up a MySQL database to allow remote client connections. This will allow other programs on remote computers to access the database.
The first step is to allow machines to connect. This is done by removing the bind-address line from the configuration file /etc/mysql/my.cnf

Once this is done restart the database to pick up the changes
/etc/init.d/mysql restart

Once the database is restarted, we need to create database user for the remote clients. We create a user called remoteuser.
CREATE USER 'remoteuser'@'%' IDENTIFIED BY 'remoteuser';

Next, we grant all permissions to remoteuser for our database, mydatabase
GRANT ALL ON mydatabase.* TO 'remoteuser'@'%';

Finally, we set the password for the user to 'remotepassword'.
SET PASSWORD FOR 'remoteuser'@'%'=password('remotepassword');

Now external clients can connect remotely to the database and should be able to execute commands against it.

Thursday, 20 March 2014

Create a Simple Kernel Module on Ubuntu

Create a file, hello.c, that prints "Hello, world" when the module is loaded and prints "Goodbye, cruel world" when the module is unloaded
#include 
#include 
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void) {
        printk(KERN_ALERT "Hello, world\n");
        return 0;
}

static void hello_exit(void) {
        printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

Create a Makefile
ifneq ($(KERNELRELEASE),)
        obj-m := hello.o

else
        KERNELDIR ?= /lib/modules/$(shell uname -r)/build
        PWD := $(shell pwd)

default:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif

Running make will create the kernel module named hello.ko
make

load the module by using the following command
sudo insmod hello.ko
View the messages by entering the dmesg command.
dmesg

unload the module by using the following command
sudo rmmod hello

Sunday, 16 March 2014

Playing Internet Radio Stations on Raspberry Pi

Install mpd and mpc. MPD is the music player and MPC is a client to control the music player
sudo apt-get install mpc mpd

Once these are installed, you just need to have a stream to play from. I found this site useful for getting streams: http://www.listenlive.eu/index.html
Add the stream to the playlist
mpc add http://stream.hoerradar.de:80/deltaradio-alternative128
Play the station using the following command.
mpc play
Use the following command to stop the player.
mpc stop
Once the station is added, you will only need to use mpc play or mpc stop to control the player.

Add Syntax Highlighting in Vim

Syntax highlighting is extremely helpful when editing code. Vim has syntax highlighting built in to it but it is not enabled by default. To enable syntax highlighting, edit the Vim configuration file, /etc/vim/vimrc, and add "syntax on" to the file and then restart Vim.