FindStyle() public method

Try to search for a GUIStyle. This functions returns NULL and does not give an error.

public FindStyle ( string styleName ) : GUIStyle
styleName string
return GUIStyle
Beispiel #1
0
    public void setProperties(Rect windowContentRect, GUIContent windowGuiContent, GUISkin skin,
				Action doMyWindowMethod, Action onExitByEscOrClose, Action onClickOutsideOfWindow)
    {
        if (windowStyle==null)
            windowStyle = skin.FindStyle(windowStyleName);
        closeButtonStyle = skin.FindStyle(closeButtonStyleName);
        this.doMyWindowMethod = doMyWindowMethod;
        this.onExitByEscOrClose = onExitByEscOrClose;
        this.onClickOutsideOfWindow = onClickOutsideOfWindow;
        this.skin = skin;
        this.windowGuiContent = windowGuiContent;

        windowRect = new Rect ( windowContentRect.x - windowStyle.padding.left,
                        windowContentRect.y - windowStyle.padding.top,
                        windowContentRect.width + windowStyle.padding.horizontal,
                        windowContentRect.height + windowStyle.padding.vertical);
        windowContentRect.x = windowStyle.padding.left;
        windowContentRect.y = windowStyle.padding.top;
        this.windowContentRect = windowContentRect;
        this.windowDragHeight = windowStyle.padding.top;

        updateDragRect();
        closeButtonHeight = closeButtonStyle.normal.background.height - closeButtonStyle.overflow.vertical;
        closeButtonWidth = closeButtonStyle.normal.background.width - closeButtonStyle.overflow.horizontal;

        int top = 8;
        int left = (int)( windowRect.width - closeButtonWidth) - 12;

        closeButtonRect = new Rect(left,
            top,
            closeButtonWidth,
            closeButtonHeight);
    }
Beispiel #2
0
        private static void UpdateStyles(GUISkin skin)
        {
            if (SearchFieldStyle == null)
            {

                SearchFieldStyle = skin.FindStyle("ToolbarSeachTextField");
                SearchCancelStyle = skin.FindStyle("ToolbarSeachCancelButton");
                ToolbarStyle = skin.FindStyle("Toolbar");
            }
        }
Beispiel #3
0
    public void setProperties(int left, int top, int contentWidth, int contentHeight, int margin, GUISkin skin)
    {
        propSingleton = PropertiesSingleton.instance;
        canvas = propSingleton.canvasWorkspaceController.canvas;
        this.left = left;
        this.top = top;
        this.margin = margin;
        this.contentWidth = contentWidth;
        this.contentHeight = contentHeight;

        horizontalScrollHeight =(int) skin.FindStyle("horizontalscrollbar").fixedHeight;

        verticalScrollWidth    =(int) skin.FindStyle("verticalscrollbar").fixedWidth;
        recalculatePositions();
    }
Beispiel #4
0
 public void setTopLeftPosition(int left, int top, GUISkin skin)
 {
     config.activeColorStyle = skin.FindStyle(config.activeColorStyleName);
     config.left = left;
     config.top = top;
     recalculatePositions();
 }
Beispiel #5
0
 //TODO - remove this part, there is skin.findStyle extension
 public static void setStyle(GUISkin skin, string styleName, out GUIStyle style)
 {
     style = skin.FindStyle(styleName);
     if (style == null){
         Debug.LogWarning("cant find "+styleName+" style, will use button one");
         style = new GUIStyle();
     }
 }
Beispiel #6
0
 public MessageWindow(Vector2 size, GUISkin skin)
 {
     this.size = size;
     this.skin = skin;
     if(skin.FindStyle("messageitem") == null) {
         //Debug.Log("Skin does not contain 'messageitem' style, reverting to default.");
         useCustomStyle = false;
     }
     scrollBarWidth = skin.verticalScrollbar.fixedWidth;
     messageWidth = size.x - scrollBarWidth - 1;
     lastTotalMessageHeight = size.y;
 }
 static public int FindStyle(IntPtr l)
 {
     try {
         UnityEngine.GUISkin self = (UnityEngine.GUISkin)checkSelf(l);
         System.String       a1;
         checkType(l, 2, out a1);
         var ret = self.FindStyle(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #8
0
    public void setTopLeftPosition(int left, int top, GUISkin skin)
    {
        config.activeToolStyle = skin.FindStyle(config.activeToolStyleName);
        config.activePassiveTooLStyle =  new GUIStyle(config.activeToolStyle);
        config.activePassiveTooLStyle.hover.background = null;
        config.activePassiveTooLStyle.active.background = null;
        config.top = top;
        config.left = left;
        activeToolRect = new Rect(left, top,config.width,config.activeToolHeight);

        stampRect = activeToolRect;
        stampRect.x+= config.iconPadding;
        stampRect.y+= config.iconPadding;
        stampRect.width = getActiveStampIcon().width;
        stampRect.height = getActiveStampIcon().height;
        PropertiesSingleton.instance.guiStampList.stampList[PropertiesSingleton.instance.activeStampId].releaseTextures();

        cloudRect = stampRect;
        cloudRect.width = config.regionOnIcon.width;
        cloudRect.height = config.regionOnIcon.height;
        setDictionaryCache();
    }
    public static bool LoadStyle()
    {
        if (IsSkinLoaded)
            return true;

        //first check if we've stored the right path
        string storedpath = EditorPrefs.GetString("xffect editor assets:");
        if (!string.IsNullOrEmpty(storedpath))
        {
            EditorAssets = storedpath;
        }

        string projectPath = Application.dataPath;
        if (projectPath.EndsWith("/Assets"))
        {
            projectPath = projectPath.Remove(projectPath.Length - ("Assets".Length));
        }

        //if can't load at the default path or the last stored path, then re-check it.
        if (!System.IO.File.Exists(projectPath + EditorAssets + "/Xskin.guiskin"))
        {
            //Initiate search
            System.IO.DirectoryInfo sdir = new System.IO.DirectoryInfo(Application.dataPath);

            Queue<System.IO.DirectoryInfo> dirQueue = new Queue<System.IO.DirectoryInfo>();
            dirQueue.Enqueue(sdir);

            bool found = false;
            while (dirQueue.Count > 0)
            {
                System.IO.DirectoryInfo dir = dirQueue.Dequeue();
                if (System.IO.File.Exists(dir.FullName + "/Xskin.guiskin"))
                {
                    string path = dir.FullName.Replace('\\', '/');
                    found = true;
                    //Remove data path from string to make it relative
                    path = path.Replace(projectPath, "");

                    if (path.StartsWith("/"))
                    {
                        path = path.Remove(0, 1);
                    }

                    EditorAssets = path;
                    Debug.Log("Located editor assets folder to '" + EditorAssets + "'");

                    EditorPrefs.SetString("xffect editor assets:", EditorAssets);

                    break;
                }
                System.IO.DirectoryInfo[] dirs = dir.GetDirectories();
                for (int i = 0; i < dirs.Length; i++)
                {
                    dirQueue.Enqueue(dirs[i]);
                }
            }

            if (!found)
            {
                Debug.LogWarning("Could not locate editor assets folder\nXffect");
                return false;
            }
        }

        XSkin = AssetDatabase.LoadAssetAtPath(EditorAssets + "/Xskin.guiskin", typeof(GUISkin)) as GUISkin;
        InspectorSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
        Xtoggle = XSkin.FindStyle("xtoggle");
        Xbutton = XSkin.FindStyle("xbutton");
        XbuttonClicked = XSkin.FindStyle("xbutton_clicked");
        XLabelField = XSkin.FindStyle("xlabelfield");
        XArea = XSkin.FindStyle("xarea");
        XTexture = XSkin.FindStyle("xtexture");
        XToggle2 = XSkin.FindStyle("xtoggle2");

        //XInfoArea = XSkin.FindStyle("xinfoarea");

        XInfoArea = InspectorSkin.FindStyle("HelpBox") ?? InspectorSkin.FindStyle("Box");

        IsSkinLoaded = true;


        //load color bkg mat

        ColorBkgMat = AssetDatabase.LoadAssetAtPath(XEditorTool.GetXffectPath() + ColorBkgMatPath, typeof(Material)) as Material;

        return true;
    }
		private static void InitializeSkins() {
			Print("Initializing Skins");
			GUIStyle tempStyle;
			List<GUIStyle> customStyles;

			gameSkin = GUI.skin;
			expSkin = AssetBase.GetGUISkin("ExperimentsDialogSkin");
			managerSkin = (GUISkin)MonoBehaviour.Instantiate(expSkin);

			customStyles = new List<GUIStyle>(managerSkin.customStyles);
			Print("Initial customStyles copied");

			tempStyle = managerSkin.window;
			tempStyle.padding = new RectOffset(8, 8, 20, 8);
			//tempStyle.fixedWidth = 375f;
			tempStyle.contentOffset = new Vector2(0, -18);
			tempStyle.overflow = new RectOffset(10, 0, 0, 0);
			Print("window modified");

			customStyles.Add(tempStyle = new GUIStyle(managerSkin.FindStyle("resultfield")));
			tempStyle.name = "selectBox";
			tempStyle.overflow = new RectOffset(0, 1, 1, 2);
			Print("selectBox added.");

			customStyles.Add(tempStyle = new GUIStyle(gameSkin.button));
			tempStyle.name = "expandButton";
			tempStyle.margin = new RectOffset(4, 0, 0, 0);
			tempStyle.padding = new RectOffset(0, 0, 0, 0);
			tempStyle.fixedHeight = 18f;
			tempStyle.fixedWidth = 20f;
			tempStyle.alignment = TextAnchor.MiddleCenter;
			tempStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			Print("expandButton added.");

			customStyles.Add(tempStyle = new GUIStyle(expSkin.button));
			tempStyle.name = "deselectButton";
			tempStyle.margin = new RectOffset(4, 4, 2, 2);
			tempStyle.padding = new RectOffset(0, 0, 0, 0);
			tempStyle.fixedHeight = 25f;
			tempStyle.fixedWidth = 25f;
			tempStyle.alignment = TextAnchor.MiddleCenter;
			tempStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");

			customStyles.Add(tempStyle = new GUIStyle(gameSkin.button));
			tempStyle.name = "selectButtonUp";
			tempStyle.margin = new RectOffset(0, 4, 0, 0);
			tempStyle.padding = new RectOffset(0, 0, 0, 0);
			tempStyle.fixedHeight = 18f;
			tempStyle.alignment = TextAnchor.MiddleLeft;
			tempStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			Print("selectButtonUp added.");

			customStyles.Add(tempStyle = new GUIStyle(tempStyle));
			tempStyle.name = "selectButtonDown";
			tempStyle.normal = tempStyle.active;
			tempStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			Print("selectButtonDown added.");

			customStyles.Add(tempStyle = new GUIStyle(gameSkin.label));
			tempStyle.name = "expandLabel";
			tempStyle.margin = new RectOffset(4, 0, 0, 0);
			tempStyle.padding = new RectOffset(0, 0, 0, 0);
			tempStyle.fixedHeight = 18f;
			tempStyle.fixedWidth = 20f;
			tempStyle.alignment = TextAnchor.MiddleCenter;
			tempStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			Print("expandLabel added.");

			customStyles.Add(tempStyle = new GUIStyle(expSkin.FindStyle("discard button")));
			tempStyle.name = "transferButton";
			tempStyle.normal.background = managerTransferNormal;
			tempStyle.hover.background = managerTransferOver;
			tempStyle.active.background = managerTransferActive;
			Print("transferButton added.");

			customStyles.Add(tempStyle = new GUIStyle(expSkin.button));
			tempStyle.name = "expandWinButton";
			tempStyle.margin = new RectOffset(8, 4, 0, 0);
			tempStyle.fixedHeight = 16f;
			tempStyle.fontSize = 11;
			tempStyle.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			tempStyle.alignment = TextAnchor.MiddleCenter;
			Print("expandWinButton added.");

			managerSkin.customStyles = customStyles.ToArray();
			Print("customStyles copied to managerSkin");
		}
    void OnGUI()
    {
        wantsMouseMove = true;

        // set up the skin if not done yet.
        if (editorSkin==null)
        {
            editorSkin = MyUtils.Utils.GetGuiSkin("VolcanicGuiSkin",out editorSkinPath);
            bg = (Texture2D)(Resources.LoadAssetAtPath(editorSkinPath+"images/bg.png",typeof(Texture2D))); // Get the texture manually as we have some trickes for bg tiling

            GUIStyleArrowInBuildSettings = editorSkin.FindStyle("Help Arrow 90 degree");

        }

        // draw the bg properly. Haven't found a way to do it with guiskin only
        if(bg!=null)
        {
            if (bg.wrapMode!= TextureWrapMode.Repeat)
            {
                bg.wrapMode = TextureWrapMode.Repeat;
            }
            GUI.DrawTextureWithTexCoords(new Rect(0,0,position.width,position.height),bg,new Rect(0, 0, position.width / bg.width, position.height / bg.height));
        }

        if (scenes==null)
        {
            //Debug.Log("Scenes = null");
            OnProjectChange();
            GUIUtility.ExitGUI();
            return;
        }

        if (!DiscreteTooBar || ShowToolBar || ShowHelp)
        {
            DrawToolStrip();
        }

        _scroll = GUILayout.BeginScrollView(_scroll);

        GUI.skin = editorSkin; // should design the scroll widgets so that it can be matching the skin.

        if (ShowHelp)
        {
            BuildHelpUI();
        }

        if (Event.current.type == EventType.Repaint)
            rowsArea = new Rect[scenes.Length];

        for(int i=0;i<scenes.Length;i++)
        {
            BuildSceneEntryUI(i);
        }

        GUILayout.FlexibleSpace();

        if (ShowHelp)
        {
            GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label("","Label Jean Fabre Sign");
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label("","Label Jean Fabre Url");
                GUILayout.EndVertical();
                GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

        }

        GUILayout.EndScrollView();

        if (Event.current.type == EventType.MouseMove)
        {
                Repaint ();
        }

        // detect mouse over top area of the browser window to toggle the toolbar visibility if required
          	if (Event.current.type == EventType.Repaint)
        {
            if (lastMousePosition!= Event.current.mousePosition)
            {
                int topDelta = ShowToolBar || ShowHelp || !DiscreteTooBar ? 20:0;

                // check if we are few pixels above the first row
                if(new Rect(0,-15,position.width,30).Contains(Event.current.mousePosition))
                {
                    ShowToolBar = true;
                }else{
                    ShowToolBar = false;
                }

                int j=0;
                mouseOverRowIndex = -1;
                foreach(Rect _row in rowsArea)
                {
                    Rect _temp = _row;
                    _temp.x = _temp.x  -_scroll.x;
                    _temp.y = _temp.y + topDelta -_scroll.y;
                    if (_temp.Contains(Event.current.mousePosition))
                    {
                        mouseOverRowIndex = j;
                        break;
                    }
                    j++;
                }
            }
            lastMousePosition = Event.current.mousePosition;
        }

        // User click on a row.
        if (Event.current.type == EventType.MouseDown && mouseOverRowIndex!=-1)
        {
            UnityEngine.Object _scene =	AssetDatabase.LoadMainAssetAtPath("Assets/"+scenes[mouseOverRowIndex]+".unity");
            if (_scene!=null)
            {
                EditorGUIUtility.PingObject(_scene.GetInstanceID());
            }
        }
    }
Beispiel #12
0
    public static void Init()
    {
        #if (UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4)
        if (isProSkin != tk2dPreferences.inst.isProSkin)
        {
            skin = null;
            isProSkin = tk2dPreferences.inst.isProSkin;
        }
        #else
        if (isProSkin != EditorGUIUtility.isProSkin)
        {
            skin = null;
            isProSkin = EditorGUIUtility.isProSkin;
        }
        #endif

        if (skin == null)
        {
            skin = AssetDatabase.LoadAssetAtPath(GetSkinPath(), typeof(GUISkin)) as GUISkin;
            if (skin != null)
            {
                sc_inspectorBG = skin.FindStyle("SC_InspectorBG");
                sc_inspectorHeaderBG = skin.FindStyle("SC_InspectorHeaderBG");
                sc_listBoxBG = skin.FindStyle("SC_ListBoxBG");
                sc_listBoxItem = skin.FindStyle("SC_ListBoxItem");
                sc_listBoxSectionHeader = skin.FindStyle("SC_ListBoxSectionHeader");
                sc_bodyBackground = skin.FindStyle("SC_BodyBackground");
                sc_dropBox = skin.FindStyle("SC_DropBox");

                toolbarSearch = skin.FindStyle("ToolbarSearch");
                toolbarSearchClear = skin.FindStyle("ToolbarSearchClear");
                toolbarSearchRightCap = skin.FindStyle("ToolbarSearchRightCap");

                anim_BG = skin.FindStyle("Anim_BG");
                anim_trigger = skin.FindStyle("Anim_Trigger");
                anim_triggerSelected = skin.FindStyle("Anim_TriggerSelected");

                whiteBox = skin.FindStyle("WhiteBox");
                selection = skin.FindStyle("Selection");
            }
        }
    }
Beispiel #13
0
	// ================================================================================================================

	public static void UseSkin()
	{
		// some stuff that can be set before test for inited
		EditorStyles.textField.wordWrap = true;
		if (EditorGUIUtility.isProSkin)
		{
			//EditorStyles.miniButtonMid.border = new RectOffset(2, 2, 0, 0); // fix a bug present in EditorStyles.miniButtonMid
		}
		else
		{
			InspectorDividerColor = new Color(0.45f, 0.45f, 0.45f, 1f);
		}

		// load the skin
		if (Skin != null)
		{
			GUI.skin = Skin;
			return;
		}

		LoadSkinTextures();

		// ----------------------------------------------------------------------------------------------------
		// init some styles that don't need skin file to define
		Skin = GUI.skin;//EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
		customStyles = Skin.customStyles;

		// text
		WarningLabelStyle = new GUIStyle(EditorStyles.label)
		{
			name = "PLYWarningLabel",
			richText = false,
			normal = { textColor = (EditorGUIUtility.isProSkin ? Color.yellow : Color.red) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, WarningLabelStyle);

		BoldLabelStyle = new GUIStyle(EditorStyles.boldLabel)
		{
			name = "PLYBoldLabel",
			richText = false,
			padding = new RectOffset(0, 0, 0, 0),
			margin = new RectOffset(3, 3, 0, 3),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, BoldLabelStyle);


		RichLabelStyle = new GUIStyle(EditorStyles.label)
		{
			name = "PLYRichLabel",
			richText = true,
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, RichLabelStyle);

		CenterLabelStyle = new GUIStyle(EditorStyles.label)
		{
			name = "PLYCenterLabel",
			richText = false,
			alignment = TextAnchor.MiddleCenter
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, CenterLabelStyle);

		Head1Style = new GUIStyle(EditorStyles.boldLabel)
		{
			name = "PLYHead1",
			richText = false,
			fontSize = 20,
			padding = new RectOffset(0, 0, 0, 0),
			margin = new RectOffset(12, 0, 3, 3),
			normal = { textColor = (EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f) : new Color(0.5f, 0.5f, 0.5f)) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, Head1Style);

		Head2Style = new GUIStyle(EditorStyles.boldLabel)
		{
			name = "PLYHead2",
			richText = false,
			fontSize = 16,
			fontStyle = FontStyle.Bold,
			padding = new RectOffset(0, 0, 0, 0),
			margin = new RectOffset(0, 0, 0, 10),
			normal = { textColor = (EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.35f, 0.35f, 0.35f)) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, Head2Style);

		Head3Style = new GUIStyle(EditorStyles.boldLabel)
		{
			name = "PLYHead3",
			richText = false,
			fontSize = 15,
			padding = new RectOffset(0, 0, 0, 0),
			margin = new RectOffset(0, 0, 0, 5),
			normal = { textColor = (EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.35f, 0.35f, 0.35f)) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, Head3Style);

		Head4Style = new GUIStyle(Head3Style)
		{
			name = "PLYHead4",
			richText = false,
			fontSize = 12,
			normal = { textColor = (EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.35f, 0.35f, 0.35f)) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, Head4Style);

		LabelRightStyle = new GUIStyle(Skin.label)
		{
			name = "PLYLabelRight",
			richText = false,
			alignment = TextAnchor.MiddleRight,
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, LabelRightStyle);

		InspectorHeadStyle = new GUIStyle(Head3Style)
		{
			name = "PLYInspectorHead",
			padding = new RectOffset(15, 0, 3, 3),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, InspectorHeadStyle);

		InspectorHeadBoxStyle = new GUIStyle(Skin.box)
		{
			name = "PLYInspectorHeadBox",
			richText = false,
			fontSize = 13,
			fontStyle = FontStyle.Bold,
			alignment = TextAnchor.MiddleLeft,
			padding = new RectOffset(25, 0, 3, 3),
			margin = new RectOffset(0, 0, 20, 10),
			stretchWidth = true,
			normal = { textColor = (EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.35f, 0.35f, 0.35f)) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, InspectorHeadBoxStyle);

		InspectorHeadFoldStyle = new GUIStyle(EditorStyles.foldout)
		{
			name = "PLYInspectorHeadFold",
			richText = false,
			fontSize = 14,
			fontStyle = FontStyle.Bold,
			padding = new RectOffset(17, 0, 0, 0),
			margin = new RectOffset(10, 10, 2, 0),
			normal = { textColor = (EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.35f, 0.35f, 0.35f)) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, InspectorHeadFoldStyle);

		HeadingFoldoutStyle = new GUIStyle(EditorStyles.foldout)
		{
			name = "PLYHeadingFoldout",
			richText = false,
			fontSize = 15,
			padding = new RectOffset(17, 0, 0, 0),
			margin = new RectOffset(0, 0, 0, 5),
			normal = { textColor = (EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.35f, 0.35f, 0.35f)) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, HeadingFoldoutStyle);

		// buttons
		ButtonStyle = new GUIStyle(Skin.button)
		{
			name = "PLYButton",
			richText = false,
			fontSize = 12,
			padding = new RectOffset(20, 20, 5, 5),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ButtonStyle);

		ButtonLeftStyle = new GUIStyle(EditorStyles.miniButtonLeft)
		{
			name = "PLYButtonLeft",
			richText = false,
			fontSize = 11,
			padding = new RectOffset(0, 0, 3, 5),
			margin = new RectOffset(2, 0, 0, 2),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ButtonLeftStyle);

		ButtonMidStyle = new GUIStyle(EditorStyles.miniButtonMid)
		{
			name = "PLYButtonMid",
			richText = false,
			fontSize = 11,
			padding = new RectOffset(0, 0, 3, 5),
			margin = new RectOffset(0, 0, 0, 2),
			border = new RectOffset(2, 2, 0, 0), // fix a bug present in EditorStyles.miniButtonMid
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ButtonMidStyle);

		ButtonRightStyle = new GUIStyle(EditorStyles.miniButtonRight)
		{
			name = "PLYButtonRight",
			richText = false,
			fontSize = 11,
			padding = new RectOffset(0, 0, 3, 5),
			margin = new RectOffset(0, 2, 0, 2),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ButtonRightStyle);

		LeftTabStyle = new GUIStyle(EditorStyles.miniButtonLeft)
		{
			name = "PLYLeftTab",
			richText = false,
			alignment = TextAnchor.MiddleLeft,
			fontSize = 10,
			fixedHeight = 24,
			stretchWidth = true,
			padding = new RectOffset(3, 3, 5, 5),
			margin = new RectOffset(3, 0, 0, 3),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, LeftTabStyle);

		TinyButton = new GUIStyle(EditorStyles.miniButton)
		{
			name = "PLYTinyButton",
			richText = false,
			fontSize = 10,
			padding = new RectOffset(2, 2, 0, 0),
			margin = new RectOffset(0, 0, 0, 0),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, TinyButton);

		ToolbarStyle = new GUIStyle(Skin.button)
		{
			name = "PLYToolbar",
			fontStyle = FontStyle.Bold,
			fontSize = 11,
			padding = new RectOffset(5, 5, 5, 5),
			overflow = new RectOffset(0, 0, 0, 1),
			onNormal = { background = Texture_ToolButtonSelected, textColor = Color.white },
			onActive = { background = Texture_ToolButtonSelected, textColor = Color.white },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ToolbarStyle);

		ToolbarButtonLeftStyle = new GUIStyle(Skin.FindStyle("ButtonLeft"))
		{
			name = "PLYToolbarLeft",
			fontStyle = FontStyle.Bold,
			fontSize = 11,
			padding = new RectOffset(5, 5, 5, 5),
			border = new RectOffset(4, 2, 2, 2),
			onNormal = { background = Texture_ToolButtonSelectedLeft },
			onActive = { background = Texture_ToolButtonSelectedLeft },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ToolbarButtonLeftStyle);

		ToolbarButtonMidStyle = new GUIStyle(Skin.FindStyle("ButtonMid"))
		{
			name = "PLYToolbarMid",
			fontStyle = FontStyle.Bold,
			fontSize = 11,
			padding = new RectOffset(5, 5, 5, 5),
			border = new RectOffset(2, 2, 2, 2),
			onNormal = { background = Texture_ToolButtonSelectedMid },
			onActive = { background = Texture_ToolButtonSelectedMid },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ToolbarButtonMidStyle);

		ToolbarButtonRightStyle = new GUIStyle(Skin.FindStyle("ButtonRight"))
		{
			name = "PLYToolbarRight",
			fontStyle = FontStyle.Bold,
			fontSize = 11,
			padding = new RectOffset(5, 5, 5, 5),
			border = new RectOffset(2, 4, 2, 2),
			onNormal = { background = Texture_ToolButtonSelectedRight },
			onActive = { background = Texture_ToolButtonSelectedRight },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ToolbarButtonRightStyle);

		// boxes and such
		DividerStyle = new GUIStyle()
		{
			name = "PLYDivider",
			border = new RectOffset(0, 0, 0, 0),
			padding = new RectOffset(0, 0, 0, 0),
			margin = new RectOffset(0, 0, 0, 0),
			normal = { background = EditorGUIUtility.whiteTexture },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, DividerStyle);

		BoxStyle = new GUIStyle(Skin.box)
		{
			name = "PLYBox",
			padding = new RectOffset(10, 10, 10, 10),
			margin = new RectOffset(5, 0, 5, 0),
			normal = { background = (EditorGUIUtility.isProSkin ? Texture_Box : Skin.box.normal.background) },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, BoxStyle);

		ScrollViewStyle = new GUIStyle(Skin.box)
		{
			name = "PLYScrollView",
			padding = new RectOffset(10, 10, 10, 10),
			margin = new RectOffset(5, 5, 5, 5),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ScrollViewStyle);

		ScrollViewNoTLMarginStyle = new GUIStyle(ScrollViewStyle)
		{
			name = "PLYScrollViewNoTLMargin",
			margin = new RectOffset(0, 5, 0, 5),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ScrollViewNoTLMarginStyle);

		ScrollViewNoMarginPaddingStyle = new GUIStyle(ScrollViewStyle)
		{
			name = "PLYScrollViewNoTLMarginNoPadding",
			padding = new RectOffset(0, 0, 3, 3),
			margin = new RectOffset(0, 0, 0, 0),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ScrollViewNoMarginPaddingStyle);

		// fields
		DelTextFieldStyle = new GUIStyle(EditorStyles.textField)
		{
			name = "PLYDelTextField",
			fixedHeight = 19,
			padding = new RectOffset(5, 5, 2, 2),
			margin = new RectOffset(EditorStyles.textField.margin.left, 0, 0, 5),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, DelTextFieldStyle);

		TextFieldStyle = new GUIStyle(EditorStyles.textField)
		{
			name = "PLYTextField",
			wordWrap = false,
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, TextFieldStyle);

		// misc
		MenuBoxStyle = new GUIStyle(BoxStyle)
		{
			name = "PLYMenuBox",
			margin = new RectOffset(1, 10, 0, 0),
			padding = new RectOffset(1, 1, 0, 0),
			normal = { background = Texture_BoxSides },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, MenuBoxStyle);

		MenuItemStyle = new GUIStyle(EditorStyles.toggle)
		{
			name = "PLYMenuItem",
			richText = false,
			fontSize = 14,
			alignment = TextAnchor.MiddleRight,
			border = new RectOffset(0, 0, 0, 0),
			margin = new RectOffset(0, 0, 0, 0),
			padding = new RectOffset(0, 10, 11, 7),
			normal = { background = null },
			hover = { background = null },
			active = { background = null },
			focused = { background = null },
			onNormal = { background = Texture_Selected, textColor = Color.white },
			onHover = { background = null },
			onActive = { background = Texture_Selected, textColor = Color.white },
			onFocused = { background = null },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, MenuItemStyle);

		MenuHeadStyle = new GUIStyle(EditorStyles.label)
		{
			name = "PLYMenuHead",
			richText = false,
			fontSize = 14,
			fontStyle = FontStyle.Bold,
			alignment = TextAnchor.MiddleRight,
			border = new RectOffset(0, 0, 0, 0),
			margin = new RectOffset(0, 0, 0, 0),
			padding = new RectOffset(0, 10, 20, 3),
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, MenuHeadStyle);

		ListItemBackDarkStyle = new GUIStyle(Skin.button)
		{
			name = "PLYListItemBackDark",
			richText = false,
			fontSize = 11,
			alignment = TextAnchor.MiddleLeft,
			clipping = TextClipping.Clip,
			stretchWidth = false,
			wordWrap = false,
			overflow = new RectOffset(0, 0, 0, 0),
			border = new RectOffset(1, 1, 1, 1),
			margin = new RectOffset(0, 0, 1, 0),
			hover = { background = Texture_FlatDarker },
			onHover = { background = Texture_FlatDarker },
			normal = { background = Texture_FlatDarker },
			active = { background = Texture_FlatDarker },
			onNormal = { background = Texture_FlatDarker },
			onActive = { background = Texture_FlatDarker },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ListItemBackDarkStyle);

		ListItemBackLightStyle = new GUIStyle(ListItemBackDarkStyle)
		{
			name = "PLYListItemBackLight",
			hover = { background = Texture_FlatLighter },
			onHover = { background = Texture_FlatLighter },
			normal = { background = Texture_FlatLighter },
			active = { background = Texture_FlatLighter },
			onNormal = { background = Texture_FlatLighter },
			onActive = { background = Texture_FlatLighter },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ListItemBackLightStyle);

		ListItemSelectedStyle = new GUIStyle(ListItemBackDarkStyle)
		{
			name = "PLYListItemSelected",
			hover = { background = Texture_Selected, textColor = Color.white },
			onHover = { background = Texture_Selected, textColor = Color.white },
			normal = { background = Texture_Selected, textColor = Color.white },
			active = { background = Texture_Selected, textColor = Color.white },
			onNormal = { background = Texture_Selected, textColor = Color.white },
			onActive = { background = Texture_Selected, textColor = Color.white },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, ListItemSelectedStyle);

		AboutLogoAreaStyle = new GUIStyle(Skin.box)
		{
			name = "PLYAboutLogoArea",
			stretchWidth = true,
			margin = new RectOffset(0,0,0,10),
			padding = new RectOffset(10,10,10,10),
			normal = { background = EditorGUIUtility.whiteTexture },
		}; ArrayUtility.Add<GUIStyle>(ref customStyles, AboutLogoAreaStyle);

		

		// finally, set it
		Skin.customStyles = customStyles;
		GUI.skin = Skin;
	}
    private GUIStyle StyleSettingsGUI(GUIStyle style)
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Name");
        style.name = EditorGUILayout.TextField(style.name);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginVertical("Box");
        showCopyStyle = EditorGUILayout.Foldout(showCopyStyle, "Copy Style from Skin");
        if (showCopyStyle)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Copy From");
            copyStyleSkin = (GUISkin)EditorGUILayout.ObjectField(copyStyleSkin, typeof(GUISkin), false);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Style Name");
            copyStyleName = EditorGUILayout.TextField(copyStyleName);
            EditorGUILayout.EndHorizontal();
            GUI.enabled = copyStyleSkin && !string.IsNullOrEmpty(copyStyleName);
            if (GUILayout.Button("COPY"))
            {
                GUIStyle copyStyle = copyStyleSkin.FindStyle(copyStyleName);
                if (copyStyle != null)
                    style = new GUIStyle(copyStyle);
                else
                    Debug.LogWarning("ERROR : No style named " + copyStyleName + " in GUISkin " + copyStyleSkin.name + " could be found!");
                copyStyleSkin = null;
                copyStyleName = "";
            }
            GUI.enabled = true;
        }
        EditorGUILayout.EndVertical();

        #region EnumPopups

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Alignment");
        style.alignment = (TextAnchor)EditorGUILayout.EnumPopup(style.alignment);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Clipping");
        style.clipping = (TextClipping)EditorGUILayout.EnumPopup(style.clipping);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Image Position");
        style.imagePosition = (ImagePosition)EditorGUILayout.EnumPopup(style.imagePosition);
        EditorGUILayout.EndHorizontal();

        #endregion
        #region Simple

        style.contentOffset = EditorGUILayout.Vector2Field("Content Offset", style.contentOffset);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Fixed Width");
        style.fixedWidth = EditorGUILayout.FloatField(style.fixedWidth);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Fixed Height");
        style.fixedHeight = EditorGUILayout.FloatField(style.fixedHeight);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Stretch Width?");
        style.stretchWidth = EditorGUILayout.Toggle(style.stretchWidth);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Stretch Height?");
        style.stretchHeight = EditorGUILayout.Toggle(style.stretchHeight);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Word Wrap?");
        style.wordWrap = EditorGUILayout.Toggle(style.wordWrap);
        EditorGUILayout.EndHorizontal();

        #endregion
        #region Groups/Complex
        #region Font

        foldFont = EditorGUILayout.Foldout(foldFont, "Font");
        if (foldFont)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Font");
            style.font = (Font)EditorGUILayout.ObjectField(style.font, typeof(Font), false);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Font Size");
            style.fontSize = EditorGUILayout.IntField(style.fontSize);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Font Style");
            style.fontStyle = (FontStyle)EditorGUILayout.EnumPopup(style.fontStyle);
            EditorGUILayout.EndHorizontal();
        }

        #endregion
        #region Rect Offsets

        style.border = RectOffset(style.border, "Border", ref foldBorder);
        style.margin = RectOffset(style.margin, "Margin", ref foldMargin);
        style.overflow = RectOffset(style.overflow, "Overflow", ref foldOverflow);
        style.padding = RectOffset(style.padding, "Padding", ref foldPadding);

        #endregion
        #endregion

        return style;
    }
Beispiel #15
0
    public void setProps(Rect itemRect, int padding, GUISkin skin)
    {
        if (styleName == "")
            _style = GUIStyle.none;
        else
            _style = skin.FindStyle(styleName);
        if (_style == null)
            _style = GUIStyle.none;

        if (textStyleName=="")
            _textStyle = GUIStyle.none;
        else
            _textStyle = skin.FindStyle(textStyleName);
        if (_textStyle == null)
            _textStyle = GUIStyle.none;

        _itemRect  = itemRect;

        int middleY =(int)( _itemRect.y + _itemRect.height / 2);
        if (contentSize.y < itemRect.height ){
            int padd =(int)( (itemRect.height - contentSize.y) / 2);
            _contentRect = new Rect (0, _itemRect.y + padding, contentSize.x, contentSize.y);
            _textRect = new Rect(_contentRect.width + padding, _itemRect.y, 0, _itemRect.height);
            _textRect.width = _itemRect.width - _textRect.x ;
        } else {
            int width =(int)((float)itemRect.height  / (float)contentSize.y * (float) contentSize.x);
            _contentRect = new Rect(0, _itemRect.y , width, itemRect.height);
            _textRect = new Rect(_contentRect.width + padding, _itemRect.y, itemRect.width - _contentRect.width - padding, itemRect.height);
        }
        _textRect.width  -= textOffset.horizontal;
        _textRect.height -= textOffset.vertical;
        _textRect.x += textOffset.left;
        _textRect.y += textOffset.top;
    }