public PUSlider(
			string handleResourcePath,
			Vector2 handleSize,
			string fillResourcePath,
			string onValueChanged,
			float minValue,
			float maxValue,
			PlanetUnity2.SliderDirection direction,
			string resourcePath )
        : this()
    {
        this.handleResourcePath = handleResourcePath;

        this.handleSize = handleSize;

        this.fillResourcePath = fillResourcePath;

        this.onValueChanged = onValueChanged;

        this.minValue = minValue;

        this.maxValue = maxValue;

        this.direction = direction;

        this.resourcePath = resourcePath;
    }
    public PUAspectFit(
			Vector2 contentSize,
			PlanetUnity2.AspectFitMode mode )
        : this()
    {
        this.contentSize = contentSize;

        this.mode = mode;
    }
Пример #3
0
    public PUCanvas(
			PlanetUnity2.CanvasRenderMode renderMode,
			bool pixelPerfect )
        : this()
    {
        this.renderMode = renderMode;

        this.pixelPerfect = pixelPerfect;
    }
    public PUHorizontalLayoutGroup(
			float spacing,
			Vector4 padding,
			PlanetUnity2.GridLayoutChildAlignment childAlignment )
        : this()
    {
        this.spacing = spacing;

        this.padding = padding;

        this.childAlignment = childAlignment;
    }
Пример #5
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);
    }
Пример #6
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);
    }
Пример #7
0
    public PUText(
			string font,
			int fontSize,
			PlanetUnity2.FontStyle fontStyle,
			Color fontColor,
			float lineSpacing,
			PlanetUnity2.TextAlignment alignment,
			string value,
			bool sizeToFit,
			int maxFontSize,
			int minFontSize,
			bool vOverflow,
			bool hOverflow,
			string onLinkClick )
        : this()
    {
        this.font = font;

        this.fontSize = fontSize;

        this.fontStyle = fontStyle;

        this.fontColor = fontColor;

        this.lineSpacing = lineSpacing;

        this.alignment = alignment;

        this.value = value;

        this.sizeToFit = sizeToFit;

        this.maxFontSize = maxFontSize;

        this.minFontSize = minFontSize;

        this.vOverflow = vOverflow;

        this.hOverflow = hOverflow;

        this.onLinkClick = onLinkClick;
    }
Пример #8
0
    public PUInputField(
			string onValueChanged,
			string placeholder,
			int limit,
			PlanetUnity2.InputFieldContentType contentType,
			PlanetUnity2.InputFieldLineType lineType,
			Color selectionColor,
			string value )
        : this()
    {
        this.onValueChanged = onValueChanged;

        this.placeholder = placeholder;

        this.limit = limit;

        this.contentType = contentType;

        this.lineType = lineType;

        this.selectionColor = selectionColor;

        this.value = value;
    }
    public PUGridLayoutGroup(
			Vector2 cellSize,
			Vector2 spacing,
			PlanetUnity2.GridLayoutStartCorner startCorner,
			PlanetUnity2.GridLayoutStartAxis startAxis,
			PlanetUnity2.GridLayoutChildAlignment childAlignment,
			int fixedRows,
			int fixedColumns )
        : this()
    {
        this.cellSize = cellSize;

        this.spacing = spacing;

        this.startCorner = startCorner;

        this.startAxis = startAxis;

        this.childAlignment = childAlignment;

        this.fixedRows = fixedRows;

        this.fixedColumns = fixedColumns;
    }
Пример #10
0
    public PUText(
			string font,
			int fontSize,
			PlanetUnity2.FontStyle fontStyle,
			Color fontColor,
			float lineSpacing,
			PlanetUnity2.TextAlignment alignment,
			string value,
			bool sizeToFit,
			int maxFontSize,
			int minFontSize,
			bool vOverflow,
			bool hOverflow,
			string onLinkClick,
			Vector4 bounds,
			Vector3 position,
			Vector2 size,
			Vector3 rotation,
			Vector3 scale,
			Vector2 pivot,
			string anchor,
			bool active,
			bool mask,
			Vector4 maskInset,
			bool outline,
			float lastY,
			float lastX,
			string shader,
			bool ignoreMouse,
			string components,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.font = font;

        this.fontSize = fontSize;

        this.fontStyle = fontStyle;

        this.fontColor = fontColor;

        this.lineSpacing = lineSpacing;

        this.alignment = alignment;

        this.value = value;

        this.sizeToFit = sizeToFit;

        this.maxFontSize = maxFontSize;

        this.minFontSize = minFontSize;

        this.vOverflow = vOverflow;

        this.hOverflow = hOverflow;

        this.onLinkClick = onLinkClick;

        this.bounds = bounds;

        this.position = position;

        this.size = size;

        this.rotation = rotation;

        this.scale = scale;

        this.pivot = pivot;

        this.anchor = anchor;

        this.active = active;

        this.mask = mask;

        this.maskInset = maskInset;

        this.outline = outline;

        this.lastY = lastY;

        this.lastX = lastX;

        this.shader = shader;

        this.ignoreMouse = ignoreMouse;

        this.components = components;

        this.title = title;

        this.tag = tag;

        this.tag1 = tag1;

        this.tag2 = tag2;

        this.tag3 = tag3;

        this.tag4 = tag4;

        this.tag5 = tag5;

        this.tag6 = tag6;
    }
Пример #11
0
    public virtual void LoadIntoPUGameObject(PUScrollRect parent, object data)
    {
        scrollRect = parent;
        cellData   = data;

        string xmlPath = XmlPath();

        if (xmlPath != null)
        {
            puGameObject = (PUGameObject)PlanetUnity2.loadXML(PlanetUnityResourceCache.GetAsset <TextAsset>(xmlPath).bytes, parent.contentObject, null);

            // 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);
            }
        }
        else
        {
            puGameObject = new PUGameObject();
            puGameObject.SetFrame(0, 0, 0, 60, 0, 0, "bottom,left");
            puGameObject.LoadIntoPUGameObject(parent);
            puGameObject.gameObject.transform.SetParent(parent.contentObject.transform, false);
        }

        puGameObject.parent = table;

        // 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(scrollRect.Scope(), name, args);
        });

        cellGameObject        = puGameObject.gameObject;
        cellTransform         = cellGameObject.transform as RectTransform;
        tableTransform        = scrollRect.rectTransform;
        tableContentTransform = scrollRect.contentObject.transform as RectTransform;

        UpdateContents();
    }
    public PUAspectFit(
			Vector2 contentSize,
			PlanetUnity2.AspectFitMode mode,
			Vector4 bounds,
			Vector3 position,
			Vector2 size,
			Vector3 rotation,
			Vector3 scale,
			Vector2 pivot,
			string anchor,
			bool active,
			bool mask,
			Vector4 maskInset,
			bool outline,
			float lastY,
			float lastX,
			string shader,
			bool ignoreMouse,
			string components,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.contentSize = contentSize;

        this.mode = mode;

        this.bounds = bounds;

        this.position = position;

        this.size = size;

        this.rotation = rotation;

        this.scale = scale;

        this.pivot = pivot;

        this.anchor = anchor;

        this.active = active;

        this.mask = mask;

        this.maskInset = maskInset;

        this.outline = outline;

        this.lastY = lastY;

        this.lastX = lastX;

        this.shader = shader;

        this.ignoreMouse = ignoreMouse;

        this.components = components;

        this.title = title;

        this.tag = tag;

        this.tag1 = tag1;

        this.tag2 = tag2;

        this.tag3 = tag3;

        this.tag4 = tag4;

        this.tag5 = tag5;

        this.tag6 = tag6;
    }
Пример #13
0
    public void LoadCanvasXML(string xml)
    {
        if (xmlPath == null || PlanetUnityOverride.xmlFromPath(xmlPath) == null)
        {
            return;
        }

        RemoveCanvas();

        Stopwatch sw = Stopwatch.StartNew();

        planetUnityContainer = GameObject.Find("PlanetUnityContainer");
        if (planetUnityContainer == null)
        {
            planetUnityContainer = new GameObject("PlanetUnityContainer");

            rootCanvas = planetUnityContainer.AddComponent <Canvas> ();
        }

        //UnityEngine.Debug.Log ("LoadCanvasXML");
        PUGameObject rootObject = (PUGameObject)PlanetUnity2.loadXML(System.Text.Encoding.UTF8.GetBytes(xml), planetUnityContainer, null);

        if (rootObject is PUCanvas)
        {
            canvas = rootObject as PUCanvas;
        }
        else
        {
            canvas = new PUCanvas(PlanetUnity2.CanvasRenderMode.ScreenSpaceCamera, false, 100);
            canvas.LoadIntoGameObject(planetUnityContainer);
            rootObject.LoadIntoPUGameObject(canvas);
        }


        // This is kind of silly, but we need to do this because we want the root canvas to match
        // the canvas of the loaded scene, but we can't just grab the contents of the sub canvas
        // because unity sets it to inherited and those contents don't persist
        if (canvas.renderMode == PlanetUnity2.CanvasRenderMode.ScreenSpaceOverlay)
        {
            rootCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
        }
        if (canvas.renderMode == PlanetUnity2.CanvasRenderMode.ScreenSpaceCamera)
        {
            GameObject puCamera = GameObject.Find("PUCamera");
            if (puCamera != null)
            {
                rootCanvas.worldCamera = puCamera.GetComponent <Camera> ();
            }
            else
            {
                rootCanvas.worldCamera = Camera.main;
            }
            rootCanvas.renderMode = RenderMode.ScreenSpaceCamera;
        }
        if (canvas.renderMode == PlanetUnity2.CanvasRenderMode.WorldSpace)
        {
            rootCanvas.renderMode = RenderMode.WorldSpace;
        }
        rootCanvas.pixelPerfect  = canvas.pixelPerfect;
        rootCanvas.planeDistance = canvas.planeDistance.Value;
        // End silly section

        // Unity 5.3: if this canvas does not override sorting, then it doesn't render in the editor (which is annoying)
        canvas.canvas.overrideSorting = true;

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

        sw.Stop();

                #if !UNITY_EDITOR
        UnityEngine.Debug.Log("[" + sw.Elapsed.TotalMilliseconds + "ms] Loading canvas " + xmlPath + ".xml");
                #endif

        //Profile.PrintResults ();
        //Profile.Reset ();
    }
    public PUHorizontalLayoutGroup(
			float spacing,
			Vector4 padding,
			PlanetUnity2.GridLayoutChildAlignment childAlignment,
			Vector4 bounds,
			Vector3 position,
			Vector2 size,
			Vector3 rotation,
			Vector3 scale,
			Vector2 pivot,
			string anchor,
			bool active,
			bool mask,
			Vector4 maskInset,
			bool outline,
			float lastY,
			float lastX,
			string shader,
			bool ignoreMouse,
			string components,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.spacing = spacing;

        this.padding = padding;

        this.childAlignment = childAlignment;

        this.bounds = bounds;

        this.position = position;

        this.size = size;

        this.rotation = rotation;

        this.scale = scale;

        this.pivot = pivot;

        this.anchor = anchor;

        this.active = active;

        this.mask = mask;

        this.maskInset = maskInset;

        this.outline = outline;

        this.lastY = lastY;

        this.lastX = lastX;

        this.shader = shader;

        this.ignoreMouse = ignoreMouse;

        this.components = components;

        this.title = title;

        this.tag = tag;

        this.tag1 = tag1;

        this.tag2 = tag2;

        this.tag3 = tag3;

        this.tag4 = tag4;

        this.tag5 = tag5;

        this.tag6 = tag6;
    }
Пример #15
0
    public PUSlider(
			string handleResourcePath,
			Vector2 handleSize,
			string fillResourcePath,
			string onValueChanged,
			float minValue,
			float maxValue,
			PlanetUnity2.SliderDirection direction,
			string resourcePath,
			Color color,
			PlanetUnity2.ImageType type,
			Vector4 bounds,
			Vector3 position,
			Vector2 size,
			Vector3 rotation,
			Vector3 scale,
			Vector2 pivot,
			string anchor,
			bool active,
			bool mask,
			Vector4 maskInset,
			bool outline,
			float lastY,
			float lastX,
			string shader,
			bool ignoreMouse,
			string components,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.handleResourcePath = handleResourcePath;

        this.handleSize = handleSize;

        this.fillResourcePath = fillResourcePath;

        this.onValueChanged = onValueChanged;

        this.minValue = minValue;

        this.maxValue = maxValue;

        this.direction = direction;

        this.resourcePath = resourcePath;

        this.color = color;

        this.type = type;

        this.bounds = bounds;

        this.position = position;

        this.size = size;

        this.rotation = rotation;

        this.scale = scale;

        this.pivot = pivot;

        this.anchor = anchor;

        this.active = active;

        this.mask = mask;

        this.maskInset = maskInset;

        this.outline = outline;

        this.lastY = lastY;

        this.lastX = lastX;

        this.shader = shader;

        this.ignoreMouse = ignoreMouse;

        this.components = components;

        this.title = title;

        this.tag = tag;

        this.tag1 = tag1;

        this.tag2 = tag2;

        this.tag3 = tag3;

        this.tag4 = tag4;

        this.tag5 = tag5;

        this.tag6 = tag6;
    }
    public PUImageButton(
			string pressedResourcePath,
			string highlightedResourcePath,
			string disabledResourcePath,
			string onTouchUp,
			string onTouchDown,
			string resourcePath,
			Color color,
			PlanetUnity2.ImageType type,
			Vector4 bounds,
			Vector3 position,
			Vector2 size,
			Vector3 rotation,
			Vector3 scale,
			Vector2 pivot,
			string anchor,
			bool active,
			bool mask,
			Vector4 maskInset,
			bool outline,
			float lastY,
			float lastX,
			string shader,
			bool ignoreMouse,
			string components,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.pressedResourcePath = pressedResourcePath;

        this.highlightedResourcePath = highlightedResourcePath;

        this.disabledResourcePath = disabledResourcePath;

        this.onTouchUp = onTouchUp;

        this.onTouchDown = onTouchDown;

        this.resourcePath = resourcePath;

        this.color = color;

        this.type = type;

        this.bounds = bounds;

        this.position = position;

        this.size = size;

        this.rotation = rotation;

        this.scale = scale;

        this.pivot = pivot;

        this.anchor = anchor;

        this.active = active;

        this.mask = mask;

        this.maskInset = maskInset;

        this.outline = outline;

        this.lastY = lastY;

        this.lastX = lastX;

        this.shader = shader;

        this.ignoreMouse = ignoreMouse;

        this.components = components;

        this.title = title;

        this.tag = tag;

        this.tag1 = tag1;

        this.tag2 = tag2;

        this.tag3 = tag3;

        this.tag4 = tag4;

        this.tag5 = tag5;

        this.tag6 = tag6;
    }
    public PUGridLayoutGroup(
			Vector2 cellSize,
			Vector2 spacing,
			PlanetUnity2.GridLayoutStartCorner startCorner,
			PlanetUnity2.GridLayoutStartAxis startAxis,
			PlanetUnity2.GridLayoutChildAlignment childAlignment,
			int fixedRows,
			int fixedColumns,
			Vector4 bounds,
			Vector3 position,
			Vector2 size,
			Vector3 rotation,
			Vector3 scale,
			Vector2 pivot,
			string anchor,
			bool active,
			bool mask,
			Vector4 maskInset,
			bool outline,
			float lastY,
			float lastX,
			string shader,
			bool ignoreMouse,
			string components,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.cellSize = cellSize;

        this.spacing = spacing;

        this.startCorner = startCorner;

        this.startAxis = startAxis;

        this.childAlignment = childAlignment;

        this.fixedRows = fixedRows;

        this.fixedColumns = fixedColumns;

        this.bounds = bounds;

        this.position = position;

        this.size = size;

        this.rotation = rotation;

        this.scale = scale;

        this.pivot = pivot;

        this.anchor = anchor;

        this.active = active;

        this.mask = mask;

        this.maskInset = maskInset;

        this.outline = outline;

        this.lastY = lastY;

        this.lastX = lastX;

        this.shader = shader;

        this.ignoreMouse = ignoreMouse;

        this.components = components;

        this.title = title;

        this.tag = tag;

        this.tag1 = tag1;

        this.tag2 = tag2;

        this.tag3 = tag3;

        this.tag4 = tag4;

        this.tag5 = tag5;

        this.tag6 = tag6;
    }