Hi,
Here's the script to sitelock your game to the domains of your choice with Unity Web Player only.
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public class SiteLock : MonoBehaviour {
public string[] domains = { "yoursite.com", "anothersite.com" };
void Awake () {
string jsarray = "[";
foreach (string domain in domains) {
jsarray += "'"+domain+"',";
}
jsarray += "]";
Application.ExternalEval("function contains(a, obj) { " +
"var i = a.length; " +
"while (i--) { if (a[i] === obj) { return true;}} " +
"return false;" +
"} "+
"if(contains("+jsarray+", document.location.host)) {} else { document.location='"+redirectUrl+"'; }");
}
}
I hope this can help.
Comments