Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Unity3D: Script to merge multiple GUISkins into a single GUISkin with multiple custom styles.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class GUIMerge : MonoBehaviour {
public GUISkin primary;
public GUISkin[] skins;
// Use this for initialization
void Start () {
var skin = skins[0];
foreach(PropertyInfo propertyInfo in typeof(GUISkin).GetProperties()) {
if (propertyInfo.PropertyType == typeof(GUISettings)) {
var settings = (GUISettings) propertyInfo.GetValue(skin, null);
primary.settings.cursorColor = settings.cursorColor;
primary.settings.cursorFlashSpeed = settings.cursorFlashSpeed;
primary.settings.doubleClickSelectsWord = settings.doubleClickSelectsWord;
primary.settings.selectionColor = settings.selectionColor;
primary.settings.tripleClickSelectsLine = settings.tripleClickSelectsLine;
else {
propertyInfo.SetValue(primary, propertyInfo.GetValue(skin, null), null);
var styleList = new List<GUIStyle>();
for (int i=0; i< skins.Length; i++) {
skin = skins[i];
var name =;
foreach(PropertyInfo propertyInfo in typeof(GUISkin).GetProperties()) {
if (propertyInfo.PropertyType != typeof(GUIStyle))
var style = (GUIStyle) propertyInfo.GetValue(skin, null);
var newname = name + "_" +;
var newstyle = new GUIStyle(style); = newname;
primary.customStyles = styleList.ToArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.