Example #1
0
    public void SetCurrentPage(OGPage page)
    {
        currentPages = new OGPage [] { page };

        foreach (OGPage p in this.GetComponentsInChildren <OGPage>(true))
        {
            if (p == page)
            {
                p.gameObject.SetActive(true);
                p.UpdateStyles();

                if (Application.isPlaying)
                {
                    p.StartPage();
                }
            }
            else if (p.gameObject.activeSelf)
            {
                if (Application.isPlaying)
                {
                    p.ExitPage();
                }

                p.gameObject.SetActive(false);
            }
        }
    }
Example #2
0
    public void AddToCurrentPages(OGPage page)
    {
        List <OGPage> pages = new List <OGPage> (currentPages);

        pages.Add(page);

        currentPages = pages.ToArray();
    }
Example #3
0
    //////////////////
    // Page management
    //////////////////
    public void RemoveFromCurrentPages(OGPage page)
    {
        List <OGPage> pages = new List <OGPage> (currentPages);

        pages.Remove(page);

        currentPages = pages.ToArray();
    }
Example #4
0
    private OGWidget [] GetCurrentWidgets()
    {
        List <OGWidget> list = new List <OGWidget> ();

        for (int i = 0; i < currentPages.Length; i++)
        {
            OGPage     page = currentPages [i];
            OGWidget[] ws   = page.gameObject.GetComponentsInChildren <OGWidget>();

            for (int w = 0; w < ws.Length; w++)
            {
                list.Add(ws [w]);
            }
        }

        return(list.OrderByDescending((w) => w.transform.position.z).ToArray());
    }
Example #5
0
 private void UpdateCurrentWidgets()
 {
     if (widgets == null)
     {
         widgets = new List <OGWidget>();
     }
     widgets.Clear();
     for (int i = 0; i < currentPages.Length; i++)
     {
         OGPage page = currentPages [i];
         ws.Clear();
         page.gameObject.GetComponentsInChildren <OGWidget>(ws);
         if (ws.Capacity < ws.Count)
         {
             ws.Capacity = ws.Count;
         }
         widgets.AddRange(ws);
     }
     if (widgets.Capacity < widgets.Count)
     {
         widgets.Capacity = widgets.Count;
     }
     widgets.Sort(WidgetCompare);
 }
Example #6
0
	public void SetCurrentPage ( OGPage page ) {
	       	currentPages = new OGPage [] { page };

		foreach ( OGPage p in this.GetComponentsInChildren<OGPage>(true) ) {
			if ( p == page ) {
				p.gameObject.SetActive ( true );
				p.UpdateStyles ();
				
				if ( Application.isPlaying ) {
					p.StartPage ();
				}

			} else if ( p.gameObject.activeSelf ) {
				if ( Application.isPlaying ) {
					p.ExitPage ();
				}

				p.gameObject.SetActive ( false );

			}
		}
	}
Example #7
0
	public void AddToCurrentPages ( OGPage page ) {
		List< OGPage > pages = new List< OGPage > ( currentPages );

		pages.Add ( page );

		currentPages = pages.ToArray ();
	}
Example #8
0
	//////////////////
	// Page management
	//////////////////
	public void RemoveFromCurrentPages ( OGPage page ) {
		List< OGPage > pages = new List< OGPage > ( currentPages );

		pages.Remove ( page );

		currentPages = pages.ToArray ();
	}
    override public void OnInspectorGUI()
    {
        serializedObject.Update();

        OGPage page = (OGPage)target;
        OGRoot root = OGRoot.GetInstance();

        if (!page || !root)
        {
            return;
        }

        DrawDefaultInspector();

        EditorGUILayout.Space();

        GUI.backgroundColor = Color.red;

        if (GUILayout.Button("Reset styles"))
        {
            page.ResetStyles();
        }

        GUI.backgroundColor = Color.green;


        foreach (OGPage p in root.currentPages)
        {
            if (p == page)
            {
                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Update", GUILayout.Height(30)))
                {
                    page.UpdateStyles();
                    GUI.backgroundColor = Color.white;
                }

                if (GUILayout.Button("-", GUILayout.Height(30), GUILayout.Width(40)))
                {
                    OGRoot.GetInstance().RemoveFromCurrentPages(page);
                    page.gameObject.SetActive(false);
                }

                GUILayout.EndHorizontal();

                return;
            }
        }

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Set current page", GUILayout.Height(30)))
        {
            OGRoot.GetInstance().SetCurrentPage(page);
            page.gameObject.SetActive(true);
        }

        if (GUILayout.Button("+", GUILayout.Height(30), GUILayout.Width(40)))
        {
            OGRoot.GetInstance().AddToCurrentPages(page);
            page.gameObject.SetActive(true);
        }

        GUILayout.EndHorizontal();

        GUI.backgroundColor = Color.white;
    }