Exemple #1
0
 public void AddListener(PUGameObject obj)
 {
     if (!_listening.Contains(obj))
     {
         _listening.Add(obj);
     }
 }
Exemple #2
0
 public static void HandleGlobalButtonOnTouchUp(PUGameObject btn)
 {
     if (GlobalButtonOnTouchUp != null)
     {
         GlobalButtonOnTouchUp(btn);
     }
 }
 public void Start()
 {
     if (xmlPath != null)
     {
         rootObject = PlanetUnityGameObject.LoadXML(xmlPath, gameObject);
     }
 }
    public override void gaxb_complete()
    {
        HideAnimation = (x, idx, direction) => {
            x.canvasGroup.alpha = 0;
            x.gameObject.SetActive(false);
        };

        ShowAnimation = (x, idx, direction) => {
            x.canvasGroup.alpha = 1;
            x.gameObject.SetActive(true);
        };

        CloseAnimation = (x, idx, block) => {
            x.canvasGroup.alpha = 0;
            x.gameObject.SetActive(false);
            block();
        };


        foreach (object childObj in children)
        {
            PUGameObject child = childObj as PUGameObject;
            child.CheckCanvasGroup();
            child.canvasGroup.alpha = 0;
            child.gameObject.SetActive(false);
        }

        int initialIndex = currentIndex.Value;

        currentIndex = -1;
        SwitchTo(initialIndex);
    }
Exemple #5
0
    public void AdvanceBuildQueue(PUGameObject shipsContainer)
    {
        if (Ships.Count > 0) {
            LDGGame game = parent as LDGGame;

            buildTime -= Time.deltaTime;
            if (buildTime <= 0) {
                LDGShip shipToProduce = Ships [0] as LDGShip;

                game.Ships.Add (shipToProduce);

                Vector3 pos = new Vector3 (857, 18, 0);

                if (shipToProduce.player == 1) {
                    pos = new Vector3 (97,586, 0);
                }

                shipToProduce.sprite = new PUSprite (shipToProduce.TexturePath(), new cVector3(0,0,0), 40.0f, new cRect (0, 0, 0, 0));
                shipToProduce.sprite.loadIntoPUGameObject (shipsContainer);
                shipToProduce.sprite.gameObject.transform.localPosition = pos;

                if (shipToProduce.player == 0) {
                    shipToProduce.sprite.gameObject.transform.localEulerAngles = new Vector3(0, 0, 180);
                }

                Ships.Remove (shipToProduce);

                if (Ships.Count > 0) {
                    LDGShip ship = Ships [0] as LDGShip;
                    buildTime = ship.buildTime ();
                }
            }
        }
    }
Exemple #6
0
    public override void Create_IMG(PUGameObject container, string url, string title)
    {
        Vector2 size = new Vector2(100, 100);

        if (title.Contains(","))
        {
            size = Vector2.zero.PUParse(title);
        }

        currentY -= paragraphSpacing();

        PUGameObject img = new PUGameObject();

        img.SetFrame(padding.left, currentY - padding.top, size.x, size.y, 0, 1, "top,left");
        img.LoadIntoPUGameObject(container);

        MarkdownRemoteImageLoader loader = img.gameObject.AddComponent <MarkdownRemoteImageLoader> ();

        loader.path       = url;
        loader.onComplete = (imgSize) => {
            img.rectTransform.sizeDelta = imgSize;
        };

        currentY -= size.y;
    }
Exemple #7
0
    public override void Create_OL_LI(PUGameObject container, string content)
    {
        if (listCounts.Peek() != 0)
        {
            currentY += DefaultFontSize() * 0.5f;
        }

        float oldY = currentY;

        padding.left += DefaultFontSize() * 2.0f;
        Create_P(container, content);
        padding.left -= DefaultFontSize() * 2.0f;

        PUTMPro text = new PUTMPro();

        text.SetFrame(padding.left, currentY - padding.top, DefaultFontSize() * 1.5f, (oldY - currentY) - DefaultFontSize(), 0, 0, "top,left");
        text.font               = DefaultFont();
        text.value              = string.Format("{0}.", listCounts.Peek() + 1);
        text.fontColor          = textColor();
        text.fontStyle          = "Bold";
        text.fontSize           = (int)(DefaultFontSize());
        text.sizeToFit          = true;
        text.alignment          = TMPro.TextAlignmentOptions.TopRight;
        text.enableWordWrapping = false;
        text.LoadIntoPUGameObject(container);

        text.textGUI.overflowMode = TMPro.TextOverflowModes.Overflow;

        listCounts.Push(listCounts.Pop() + 1);
    }
Exemple #8
0
    public static void CreateGradient(GameObject gameObject, PUGameObject puGameObject, cRect bounds, cVector2 anchor, Color a, Color b, string shader)
    {
        Mesh mesh = new Mesh ();

        Vector3[] vertices = new Vector3[] {
            new Vector3 (bounds.w - bounds.w * anchor.x, bounds.h - bounds.h * anchor.y, 0.0f),
            new Vector3 (bounds.w - bounds.w * anchor.x, -bounds.h * anchor.y, 0.0f),
            new Vector3 (0.0f - bounds.w * anchor.x, bounds.h - bounds.h * anchor.y, 0.0f),
            new Vector3 (0.0f - bounds.w * anchor.x, -bounds.h * anchor.y, 0.0f),
        };

        int[] triangles = new int[] {
            0, 1, 2,
            2, 1, 3,
        };

        mesh.vertices = vertices;
        mesh.colors = new Color[4] {Color.white, Color.white, Color.white, Color.white};
        mesh.triangles = triangles;
        mesh.RecalculateNormals ();

        MeshFilter filter = (MeshFilter)gameObject.GetComponent (typeof(MeshFilter));
        filter.mesh = mesh;

        if (shader == null) {
            shader = "PlanetUnity/Color";
        }

        var shaderObj = Shader.Find (puGameObject.fullShaderPath(shader));
        Material mat = new Material (shaderObj);
        gameObject.renderer.material = mat;
        gameObject.renderer.material.color = a;
    }
    public virtual PUTMPro AddTextWithOptions(PUGameObject container, string content, string fontPath, Color color, float fontScale, string style, TMPro.TextAlignmentOptions alignment)
    {
        if (currentY != 0) {
            currentY -= paragraphSpacing ();
        }

        float maxWidth = container.size.Value.x - (padding.left + padding.right);

        PUTMPro text = new PUTMPro ();
        text.SetFrame (padding.left, currentY - padding.top, maxWidth, 0, 0, 1, "top,left");
        text.font = fontPath;
        text.fontColor = color;
        text.fontStyle = style;
        text.fontSize = (int)(DefaultFontSize()*fontScale);
        text.sizeToFit = true;
        text.alignment = alignment;
        text.value = content;

        if (urlLinks.Count > 0) {
            string[] linkURLs = urlLinks.ToArray();
            text.OnLinkClickAction = (linkText,linkIdx) => {
                OpenLink(linkURLs[linkIdx]);
            };
            urlLinks.Clear();
        }

        text.LoadIntoPUGameObject (container);

        Vector2 size = text.CalculateTextSize (content, maxWidth);
        text.rectTransform.sizeDelta = size;

        currentY -= text.rectTransform.sizeDelta.y + padding.bottom;

        return text;
    }
    public void LoadIntoPUGameObject(PUGameObject _parent, Action doChildren = null)
    {
        // Sanity check to make sure this wasn't called multiple times
        if (gameObject == null)
        {
            gaxb_load(null, null, null);
            gaxb_init();
            gaxb_final(null, _parent, null);
        }

        parent = _parent;

        if (_parent != null)
        {
            if (_parent is PUScrollRect)
            {
                gameObject.transform.SetParent((_parent as PUScrollRect).contentObject.transform, false);
            }
            else
            {
                gameObject.transform.SetParent(_parent.gameObject.transform, false);
            }

            _parent.children.Add(this);
        }

        if (doChildren != null)
        {
            doChildren();
        }

        gaxb_complete();
        gaxb_private_complete();
    }
    public virtual void unload()
    {
        PUGameObject p = parent as PUGameObject;

        if (p != null)
        {
            p.removeChild(this);
        }

        this.PerformOnChildren(val => {
            MethodInfo method = val.GetType().GetMethod("gaxb_unload");
            if (method != null)
            {
                method.Invoke(val, null);
            }
            return(true);
        });

        unloadAllChildren();

        NotificationCenter.removeObserver(this);

        if (gameObject != null)
        {
            gameObject.SetActive(false);
            GameObject.Destroy(gameObject);
            gameObject = null;
        }
        rectTransform = null;
    }
Exemple #12
0
    public static void AttachAllElements(object controller, PUObject scene)
    {
        if (scene != null)
        {
            FieldInfo field = controller.GetType().GetField("scene");
            if (field != null)
            {
                field.SetValue(controller, scene);
            }

            scene.PerformOnChildren(val =>
            {
                PUGameObject oo = val as PUGameObject;
                if (oo != null && oo.title != null)
                {
                    field = controller.GetType().GetField(oo.title);
                    if (field != null)
                    {
                        try{
                            field.SetValue(controller, oo);
                        }catch (Exception e) {
                            UnityEngine.Debug.Log("Controller error: " + e);
                        }
                    }
                }
                return(true);
            });
        }
    }
Exemple #13
0
    public override void Create_DefinitionData(PUGameObject container, string content)
    {
        currentY += DefaultFontSize() * 0.8f;

        padding.left += DefaultFontSize() * 1.0f;
        AddTextWithOptions(container, content, DefaultFont(), textColor(), 0.8f, "Normal", TMPro.TextAlignmentOptions.Left);
        padding.left -= DefaultFontSize() * 1.0f;
    }
 private void ShowIndex(int idx, int direction)
 {
     if (idx >= 0 && idx < children.Count)
     {
         PUGameObject child = children [idx] as PUGameObject;
         ShowAnimation(child, idx, direction);
     }
 }
Exemple #15
0
 private void ShowIndex(int idx, float delay)
 {
     if (idx >= 0 && idx < children.Count)
     {
         PUGameObject child = children [idx] as PUGameObject;
         ShowAnimation(child, idx);
     }
 }
Exemple #16
0
 public virtual void unloadAllChildren()
 {
     for (int i = children.Count - 1; i >= 0; i--)
     {
         PUGameObject p = children [i] as PUGameObject;
         p.unload();
     }
     children.Clear();
 }
Exemple #17
0
    private static string evaluateString(string evalListString, object o, float multiplier, Func <decimal, decimal> appOverride = null)
    {
        var parts = Regex.Split(evalListString, ",(?![^(]*\\))");

        RectTransform rectTransform = null;

        mathParser.LocalVariables ["dpi"]     = Convert.ToDecimal(PlanetUnityOverride.screenDPI());
        mathParser.LocalVariables ["screenW"] = Convert.ToDecimal(Screen.width / multiplier);
        mathParser.LocalVariables ["screenH"] = Convert.ToDecimal(Screen.height / multiplier);

                #if UNITY_IOS
        mathParser.LocalVariables ["statusBarHeight"] = Convert.ToDecimal((0.13f * PlanetUnityOverride.screenDPI()) / multiplier);
                #else
        mathParser.LocalVariables ["statusBarHeight"] = 0;
                #endif

        GameObject   parentAsGameObject   = o as GameObject;
        PUGameObject parentAsPUGameObject = o as PUGameObject;

        if (parentAsGameObject != null)
        {
            rectTransform = parentAsGameObject.GetComponent <RectTransform> ();
        }
        else if (parentAsPUGameObject != null)
        {
            rectTransform = parentAsPUGameObject.gameObject.GetComponent <RectTransform> ();
        }

        if (rectTransform)
        {
            // Work around for unity stretching canvas bug
            if (o is PUCanvas && (int)rectTransform.rect.width == 100 && (int)rectTransform.rect.height == 100)
            {
                mathParser.LocalVariables ["w"] = Convert.ToDecimal(Screen.width / multiplier);
                mathParser.LocalVariables ["h"] = Convert.ToDecimal(Screen.height / multiplier);
            }
            else
            {
                mathParser.LocalVariables ["w"] = Convert.ToDecimal(rectTransform.rect.width / multiplier);
                mathParser.LocalVariables ["h"] = Convert.ToDecimal(rectTransform.rect.height / multiplier);
            }
        }

        evalStringBuilder.Length = 0;
        foreach (string part in parts)
        {
            decimal result = (mathParser.Parse(part) * (decimal)multiplier);
            if (appOverride != null)
            {
                result = appOverride(result);
            }
            evalStringBuilder.AppendFormat("{0},", result);
        }
        evalStringBuilder.Length = evalStringBuilder.Length - 1;

        return(evalStringBuilder.ToString());
    }
Exemple #18
0
    public override void Create_HR(PUGameObject container)
    {
        currentY -= paragraphSpacing();

        PUColor color = new PUColor();

        color.color = new Color(0.8f, 0.8f, 0.8f, 1.0f);
        color.SetFrame(padding.left + 2, currentY, 0, 1, 0, 0, "top,left");
        color.LoadIntoPUGameObject(container);
    }
Exemple #19
0
 public virtual void Tag_Emphasis(PUGameObject container, StringBuilder content, bool isOpen)
 {
     if (isOpen)
     {
         content.Append("<i>");
     }
     else
     {
         content.Append("</i>");
     }
 }
Exemple #20
0
 public PUTableCell TableCellForPUGameObject(PUGameObject baseObject)
 {
     foreach (PUTableCell cell in allCells)
     {
         if (cell.puGameObject.Equals(baseObject))
         {
             return(cell);
         }
     }
     return(null);
 }
Exemple #21
0
 public virtual void Tag_Strong(PUGameObject container, StringBuilder content, bool isOpen)
 {
     if (isOpen)
     {
         content.Append("<b>");
     }
     else
     {
         content.Append("</b>");
     }
 }
 public void Close(Action block)
 {
     if (currentIndex.Value >= 0 && currentIndex.Value < children.Count)
     {
         PUGameObject child = children [currentIndex.Value] as PUGameObject;
         CloseAnimation(child, currentIndex.Value, block);
     }
     else
     {
         block();
     }
 }
Exemple #23
0
 public virtual bool Tag_Code(PUGameObject container, StringBuilder content, String codeContent, bool isOpen)
 {
     if (isOpen)
     {
         content.Append("<u>");
     }
     else
     {
         content.Append("</u>");
     }
     return(true);
 }
Exemple #24
0
    public PUSprite GetSprite(PUGameObject parent)
    {
        if (sprite == null) {
            sprite = new PUSprite ("game/equipment" + icon, position, baseScale, new cRect(0,0,0,0));
            sprite.loadIntoPUGameObject (parent);
            sprite.gameObject.transform.localPosition = new Vector3 (position.x, position.y, position.z);

            sprite.gameCollider2D = (CircleCollider2D) sprite.gameObject.AddComponent(typeof(CircleCollider2D));
            CircleCollider2D circleCollider = sprite.gameCollider2D as CircleCollider2D;
            circleCollider.radius = 0.2f;
        }
        return sprite;
    }
Exemple #25
0
    public static string processString(object cur, object o, string s)
    {
        if (s == null)
        {
            return(null);
        }

                #if USE_LAURETTE
        s = s.Replace("@LANGUAGE", Localizations.GetLanguageCode());
                #endif
        s = s.Replace("\\n", "\n");

        if (s.Equals("nan"))
        {
            return("0");
        }

        if (s.StartsWith("@localization("))
        {
                        #if USE_LAURETTE
            string evalListString = s.Substring(14, s.Length - 15);
            s = Localizations.TranslateKey(evalListString);
                        #endif
        }
        else if (s.StartsWith("@eval("))
        {
            string evalListString = s.Substring(6, s.Length - 7);
            s = evaluateString(evalListString, o, 1.0f);

            PUGameObject current = cur as PUGameObject;
            if (current != null)
            {
                foreach (var token in mathParser.usedTokens)
                {
                    current.Canvas.GetVariable(token).AddListener(current);
                }
            }
        }
        else if (s.StartsWith("@dpi("))
        {
            string evalListString = s.Substring(5, s.Length - 6);
            s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI());
        }
        else if (s.StartsWith("@app1("))
        {
            string evalListString = s.Substring(6, s.Length - 7);
            s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI(), PlanetUnityOverride.app1);
        }

        return(PlanetUnityOverride.appProcessString(s));
    }
Exemple #26
0
    public override void End_Blockquote(PUGameObject container)
    {
        padding.left -= 16;

        float topY = blockquotesTop.Peek();

        blockquotesTop.Pop();

        PUColor color = new PUColor();

        color.color = new Color(0.8f, 0.8f, 0.8f, 1.0f);
        color.SetFrame(padding.left + 2, currentY, 4, Mathf.Abs(topY - currentY), 0, 0, "top,left");
        color.LoadIntoPUGameObject(container);
    }
Exemple #27
0
    public static void CreateGradient(GameObject gameObject, PUGameObject puGameObject, string meshName, cRect bounds, cVector2 anchor, Color a, Color b, string shader)
    {
        Transform model = Resources.Load<GameObject> (meshName).transform;
        Mesh mesh = null;
        foreach (Transform t in model.transform) {
            MeshFilter loadedFilter = (MeshFilter)t.GetComponent (typeof(MeshFilter));
            if (loadedFilter != null) {
                mesh = loadedFilter.mesh;
                break;
            }
        }

        mesh = (Mesh)Mesh.Instantiate(mesh);

        /*
        // Scale the mesh by the width and the height...
        Vector3[] vertices = new Vector3[mesh.vertexCount];
        for(int i = 0; i < mesh.vertexCount; i++){
            Vector3 v = mesh.vertices [i];
            v.x *= bounds.w;
            v.y *= bounds.h;
            vertices [i] = v;
        }
        mesh.vertices = vertices;*/

        Vector3[] vertices = mesh.vertices;
        int i = 0;
        while (i < vertices.Length) {
            vertices [i].x *= bounds.w;
            vertices [i].y *= bounds.h;
            i++;
        }
        mesh.vertices = vertices;

        mesh.RecalculateBounds ();

        MeshFilter filter = (MeshFilter)gameObject.GetComponent (typeof(MeshFilter));
        filter.sharedMesh = mesh;

        if (shader == null) {
            shader = "PlanetUnity/Color";
        }

        var shaderObj = Shader.Find (puGameObject.fullShaderPath(shader));
        Material mat = new Material (shaderObj);
        gameObject.renderer.material = mat;
        gameObject.renderer.material.color = a;
    }
Exemple #28
0
    public override void Create_CodeBlock(PUGameObject container, string content)
    {
        float margin = 10;

        padding.left  += DefaultFontSize() * 2.0f;
        padding.right += DefaultFontSize() * 2.0f;

        PUTMPro text = AddTextWithOptions(container, content, DefaultFont(), textColor(), 0.8f, "Normal", TMPro.TextAlignmentOptions.Left);

        PutTextInBox(container, text, margin, new Color32(204, 204, 204, 255), new Color32(248, 248, 248, 255));

        padding.left  -= DefaultFontSize() * 2.0f;
        padding.right -= DefaultFontSize() * 2.0f;

        currentY -= margin;
    }
Exemple #29
0
    static public PUGameObject LoadXML(string xmlPath, GameObject parent)
    {
        PUGameObject loadedGameObject = (PUGameObject)PlanetUnity2.loadXML(PlanetUnityResourceCache.GetAsset <TextAsset>(xmlPath).bytes, parent, null);

                #if UNITY_EDITOR
        if (planetUnityContainer != null)
        {
            foreach (Transform t in planetUnityContainer.GetComponentsInChildren <Transform>())
            {
                t.gameObject.hideFlags = HideFlags.DontSave;
            }
        }
                #endif

        return(loadedGameObject);
    }
Exemple #30
0
    static public PUGameObject LoadXML(string xmlPath, PUGameObject parent)
    {
        PUGameObject loadedGameObject = (PUGameObject)PlanetUnity2.loadXML(PlanetUnityOverride.xmlFromPath(xmlPath), parent, null);

                #if UNITY_EDITOR
        if (planetUnityContainer != null)
        {
            foreach (Transform t in planetUnityContainer.GetComponentsInChildren <Transform>())
            {
                t.gameObject.hideFlags = HideFlags.DontSave;
            }
        }
                #endif

        return(loadedGameObject);
    }
Exemple #31
0
    public string HeirarchyPath()
    {
        StringBuilder sb = new StringBuilder();
        PUGameObject  t  = this;

        while (t != null)
        {
            PUGameObject p = t.parent as PUGameObject;
            sb.AppendFormat("{0}.", t.GetType().Name);
            if (p != null)
            {
                sb.AppendFormat("{0}.", p.children.IndexOf(t));
            }
            t = p;
        }
        return(sb.ToString());
    }
Exemple #32
0
    public static void SetOnTouchUp(PUGameObject gmObj, Button btn, string newNote)
    {
        if (btn != null && newNote != null)
        {
            btn.onClick.RemoveAllListeners();

            btn.onClick.AddListener(() => {
                if (gmObj != null)
                {
                    NotificationCenter.postNotification(gmObj.Scope(), newNote, NotificationCenter.Args("sender", gmObj));
                }
                else
                {
                    NotificationCenter.postNotification(null, newNote);
                }
            });
        }
    }
    public void UpdateKetchupIndicators()
    {
        // If we don't have enough indicators
        while (KetchupIndicators.children.Count < NumberOfKetchupUses)
        {
            PURawImage i = new PURawImage();
            i.SetFrame(KetchupIndicators.children.Count * 26 + 4, 2, 28, 58, 0, 0, "bottom,left");
            i.resourcePath = "Game/ketchup_indicator";
            i.LoadIntoPUGameObject(KetchupIndicators);
        }

        // If we have too many indicators
        while (KetchupIndicators.children.Count > NumberOfKetchupUses)
        {
            PUGameObject lastObject = KetchupIndicators.children [KetchupIndicators.children.Count - 1] as PUGameObject;
            lastObject.unload();
        }
    }
Exemple #34
0
    public static void SetOnTouchDown(PUGameObject gmObj, Button btn, string newNote)
    {
        if (btn != null)
        {
            // check if the ButtonOnDownBehaviour component exists
            ButtonOnDownBehaviour onDownBehavior = btn.GetComponent <ButtonOnDownBehaviour> ();

            // if we don't then add one
            if (onDownBehavior == null)
            {
                onDownBehavior = btn.gameObject.AddComponent <ButtonOnDownBehaviour> ();
            }

            // set the note info
            onDownBehavior.scopeObj = gmObj;
            onDownBehavior.note     = newNote;
        }
    }
Exemple #35
0
    public virtual PUTMPro AddTextWithOptions(PUGameObject container, string content, string fontPath, Color color, float fontScale, string style, TMPro.TextAlignmentOptions alignment)
    {
        if (currentY != 0)
        {
            currentY -= paragraphSpacing();
        }

        float maxWidth = container.size.Value.x - (padding.left + padding.right);

        PUTMPro text = new PUTMPro();

        text.SetFrame(padding.left, currentY - padding.top, maxWidth, 0, 0, 1, "top,left");
        text.font      = fontPath;
        text.fontColor = color;
        text.fontStyle = style;
        text.fontSize  = (int)(DefaultFontSize() * fontScale);
        text.sizeToFit = true;
        text.alignment = alignment;
        text.value     = content;

        if (urlLinks.Count > 0)
        {
            string[] linkURLs = urlLinks.ToArray();
            text.OnLinkClickAction = (linkText, linkIdx) => {
                OpenLink(linkURLs[linkIdx]);
            };
            urlLinks.Clear();
        }

        text.LoadIntoPUGameObject(container);



        Vector2 size = text.CalculateTextSize(content, maxWidth);

        text.rectTransform.sizeDelta = size;

        currentY -= text.rectTransform.sizeDelta.y + padding.bottom;

        return(text);
    }
 public virtual void Tag_Link(PUGameObject container, StringBuilder content, string url, string text)
 {
     content.AppendFormat ("[link]{0}[/link]", text);
 }
 public virtual void Tag_Strong(PUGameObject container, StringBuilder content, bool isOpen)
 {
     if (isOpen) {
         content.Append ("<b>");
     } else {
         content.Append ("</b>");
     }
 }
Exemple #38
0
    public virtual void LoadIntoPUGameObject(PUTable parent, object data, int baseRenderQueue)
    {
        table = parent;
        cellData = data;

        puGameObject = (PUGameObject)PlanetUnity.loadXML (PlanetUnityOverride.xmlFromPath(XmlPath ()), parent, NotificationCenter.Args ("baseRenderQueue", baseRenderQueue));

        // Attach all of the PlanetUnity objects
        try {
            FieldInfo field = this.GetType ().GetField ("scene");
            if (field != null) {
                field.SetValue (this, puGameObject);
            }

            puGameObject.performOnChildren (val => {
                PUGameObject oo = val as PUGameObject;
                if (oo != null && oo.title != null) {
                    field = this.GetType ().GetField (oo.title);
                    if (field != null) {
                        field.SetValue (this, oo);
                    }
                }
                return true;
            });
        } catch (Exception e) {
            UnityEngine.Debug.Log ("TableCell error: " + e);
        }

        try {
            // Attach all of the named GameObjects
            FieldInfo[] fields = this.GetType ().GetFields ();
            foreach (FieldInfo field in fields) {
                if (field.FieldType == typeof(GameObject)) {

                    GameObject[] pAllObjects = (GameObject[])Resources.FindObjectsOfTypeAll (typeof(GameObject));

                    foreach (GameObject pObject in pAllObjects) {
                        if (pObject.name.Equals (field.Name)) {
                            field.SetValue (this, pObject);
                        }
                    }
                }
            }
        } catch (Exception e) {
            UnityEngine.Debug.Log ("TableCell error: " + e);
        }

        if (IsHeader ()) {
            PUTableHeaderScript script = (PUTableHeaderScript)puGameObject.gameObject.AddComponent (typeof(PUTableHeaderScript));
            script.table = table;
            script.tableCell = this;
        }

        // We want to bridge all notifications to my scope; this allows developers to handle notifications
        // at the table cell level, or at the scene controller level, with ease
        NotificationCenter.addObserver (this, "*", puGameObject, (args,name) => {
            NotificationCenter.postNotification(table.scope(), name, args);
        });
    }
 public override void Begin(PUGameObject container)
 {
     currentY = 0;
     blockquotesTop.Clear ();
 }
    public void PutTextInBox(PUGameObject container, PUTMPro text, float margin, Color outlineColor, Color backgroundColor)
    {
        PUColor outlineColorGO = new PUColor ();
        outlineColorGO.color = outlineColor;
        outlineColorGO.SetFrame (text.rectTransform.anchoredPosition.x,text.rectTransform.anchoredPosition.y,text.rectTransform.sizeDelta.x + margin * 2.0f,text.rectTransform.sizeDelta.y + margin * 2.0f,0,1,"top,left");
        outlineColorGO.LoadIntoPUGameObject (container);

        PUColor backgroundColorGO = new PUColor ();
        backgroundColorGO.color = backgroundColor;
        backgroundColorGO.SetFrame (0, 0, 0, 0, 0, 0, "stretch,stretch");
        backgroundColorGO.LoadIntoPUGameObject (outlineColorGO);
        backgroundColorGO.SetStretchStretch (1, 1, 1, 1);

        text.rectTransform.SetParent (outlineColorGO.rectTransform, false);
        text.rectTransform.pivot = Vector2.zero;
        text.rectTransform.anchorMax = Vector2.one;
        text.rectTransform.anchorMin = Vector2.zero;
        text.SetStretchStretch (margin, margin, margin, margin);
    }
    public override void Create_CodeBlock(PUGameObject container, string content)
    {
        float margin = 10;

        padding.left += DefaultFontSize() * 2.0f;
        padding.right += DefaultFontSize() * 2.0f;

        PUTMPro text = AddTextWithOptions (container, content, DefaultFont(), textColor(), 0.8f, "Normal", TMPro.TextAlignmentOptions.Left);

        PutTextInBox (container, text, margin, new Color32 (204, 204, 204, 255), new Color32 (248, 248, 248, 255));

        padding.left -= DefaultFontSize() * 2.0f;
        padding.right -= DefaultFontSize() * 2.0f;

        currentY -= margin;
    }
 public override void Begin_Blockquote(PUGameObject container)
 {
     padding.left += 16;
     blockquotesTop.Push (currentY - DefaultFontSize());
 }
 public virtual void Begin_OrderedList(PUGameObject container)
 {
 }
 public virtual void Begin(PUGameObject container)
 {
 }
 public virtual void Create_IMG(PUGameObject container, string url, string title)
 {
 }
 public virtual void Create_HR(PUGameObject container)
 {
 }
 public virtual void Create_DefinitionTerm(PUGameObject container, string content)
 {
 }
 public virtual void Create_CodeBlock(PUGameObject container, string content)
 {
 }
 public override void End_UnorderedList(PUGameObject container)
 {
     listCounts.Pop ();
 }
 public virtual void Create_UL_LI(PUGameObject container, string content)
 {
 }
    public void LoadIntoPUGameObject(PUGameObject _parent, Action doChildren = null)
    {
        // Sanity check to make sure this wasn't called multiple times
        if (gameObject == null) {
            gaxb_load (null, null, null);
            gaxb_init ();
            gaxb_final (null, _parent, null);
        }

        parent = _parent;

        if (_parent != null) {
            if (_parent is PUScrollRect) {
                gameObject.transform.SetParent ((_parent as PUScrollRect).contentObject.transform, false);
            } else {
                gameObject.transform.SetParent (_parent.gameObject.transform, false);
            }

            _parent.children.Add (this);
        }

        if (doChildren != null) {
            doChildren();
        }

        gaxb_complete ();
        gaxb_private_complete ();
    }
 public virtual void End(PUGameObject container)
 {
 }
 public override void Begin_UnorderedList(PUGameObject container)
 {
     listCounts.Push (0);
 }
 public virtual void End_Blockquote(PUGameObject container)
 {
 }
 public virtual void End_UnorderedList(PUGameObject container)
 {
 }
 public virtual void Tag_BreakingReturn(PUGameObject container, StringBuilder content)
 {
     content.Append ("\n");
 }
Exemple #57
0
 public void loadIntoPUGameObject(PUGameObject _parent)
 {
     parent = _parent;
     _parent.children.Add (this);
     loadIntoGameObject (_parent.contentGameObject());
 }
 public virtual void Tag_Emphasis(PUGameObject container, StringBuilder content, bool isOpen)
 {
     if (isOpen) {
         content.Append ("<i>");
     } else {
         content.Append ("</i>");
     }
 }
 public virtual void Create_Table(PUGameObject container, TableSpec table)
 {
 }
 public override void Tag_Link(PUGameObject container, StringBuilder content, string url, string text)
 {
     urlLinks.Add (url);
     content.AppendFormat ("<#5a92c9ff><link>{0}</link></color>", text);
 }