コード例 #1
0
    public override void SetSize(float width, float height)
    {
        base.SetSize(width, height);

        if (emptySprite == null)
        {
            return;
        }

        emptySprite.SetSize(width, height);
    }
コード例 #2
0
ファイル: UISlider.cs プロジェクト: hhs900110/ProjectKT
    public override void SetSize(float width, float height)
    {
        base.SetSize(width, height);

        if (knob == null)
        {
            return;
        }

        knob.SetStartPos(CalcKnobStartPos());
        knob.SetMaxScroll(width - (stopKnobFromEdge * 2f));
        knob.SetPosition(m_value);
        emptySprite.SetSize(width, height);
    }
コード例 #3
0
    protected void CreateCaret()
    {
        // Create our caret and hide it by default:
        GameObject go = new GameObject();

        go.name                    = name + " - caret";
        go.transform.parent        = transform;
        go.transform.localPosition = Vector3.zero;
        go.transform.localRotation = Quaternion.identity;
        go.transform.localScale    = Vector3.one;
        go.layer                   = gameObject.layer;
        caret        = (AutoSprite)go.AddComponent(typeof(AutoSprite));
        caret.plane  = plane;
        caret.offset = caretOffset;
        caret.SetAnchor(caretAnchor);
        caret.persistent = persistent;
        if (!managed)
        {
            if (caret.spriteMesh != null)
            {
                ((SpriteMesh)caret.spriteMesh).material = renderer.sharedMaterial;
            }
        }
        else
        {
            if (manager != null)
            {
                caret.Managed = managed;
                manager.AddSprite(caret);
                caret.SetDrawLayer(drawLayer + 1);                      // Caret should be drawn in front of the field graphic
            }
            else
            {
                Debug.LogError("Sprite on object \"" + name + "\" not assigned to a SpriteManager!");
            }
        }
        caret.autoResize = autoResize;
        if (pixelPerfect)
        {
            caret.pixelPerfect = pixelPerfect;
        }
        else
        {
            caret.SetSize(caretSize.x, caretSize.y);
        }

        if (states[1].spriteFrames.Length != 0)
        {
            caret.animations    = new UVAnimation[1];
            caret.animations[0] = new UVAnimation();
            caret.animations[0].SetAnim(states[1], 0);
            caret.PlayAnim(0, 0);
        }
        caret.renderCamera = renderCamera;
        caret.SetCamera(renderCamera);
        caret.Hide(true);
        transitions[1].list[0].MainSubject = caret.gameObject;

        PositionCaret();

        if (container != null)
        {
            container.AddSubject(caret.gameObject);
        }
    }
コード例 #4
0
	protected void CreateCaret()
	{
		// Create our caret and hide it by default:
		GameObject go = new GameObject();
		go.name = name + " - caret";
		go.transform.parent = transform;
		go.transform.localPosition = Vector3.zero;
		go.transform.localRotation = Quaternion.identity;
		go.transform.localScale = Vector3.one;
		go.layer = gameObject.layer;
		caret = (AutoSprite)go.AddComponent(typeof(AutoSprite));
		caret.plane = plane;
		caret.offset = caretOffset;
		caret.SetAnchor(caretAnchor);
		caret.persistent = persistent;
		if (!managed)
		{
			if (caret.spriteMesh != null)
				((SpriteMesh)caret.spriteMesh).material = renderer.sharedMaterial;
		}
		else
		{
			if (manager != null)
			{
				caret.Managed = managed;
				manager.AddSprite(caret);
				caret.SetDrawLayer(drawLayer + 1);	// Caret should be drawn in front of the field graphic
			}
			else
				Debug.LogError("Sprite on object \"" + name + "\" not assigned to a SpriteManager!");
		}
		caret.autoResize = autoResize;
		if (pixelPerfect)
			caret.pixelPerfect = pixelPerfect;
		else
			caret.SetSize(caretSize.x, caretSize.y);

		if (states[1].spriteFrames.Length != 0)
		{
			caret.animations = new UVAnimation[1];
			caret.animations[0] = new UVAnimation();
			caret.animations[0].SetAnim(states[1], 0);
			caret.PlayAnim(0, 0);
		}
		caret.renderCamera = renderCamera;
		caret.SetCamera(renderCamera);
		caret.Hide(true);
		transitions[1].list[0].MainSubject = caret.gameObject;

		PositionCaret();

		if (container != null)
			container.AddSubject(caret.gameObject);
	}
コード例 #5
0
	protected override void Start()
	{
		base.Start();

		// Create a TextMesh object if none exists:
		if (spriteText == null)
		{
			Text = " ";
			Text = "";
		}

		if(spriteText != null)
		{
			origTextPos = spriteText.transform.localPosition;
			SetMargins(margins);
		}

		// Set the insertion point to the end by default:
		insert = Text.Length;

		// Runtime init stuff:
		if (Application.isPlaying)
		{
			// Create a default collider if none exists:
			if (collider == null)
				AddCollider();

			// Create our caret and hide it by default:
			GameObject go = new GameObject();
			go.name = name + " - caret";
			go.transform.parent = transform;
			go.transform.localPosition = Vector3.zero;
			go.transform.localRotation = Quaternion.identity;
			go.transform.localScale = Vector3.one;
			go.layer = gameObject.layer;
			caret = (AutoSprite)go.AddComponent(typeof(AutoSprite));
			caret.plane = plane;
			caret.offset = caretOffset;
			caret.SetAnchor(caretAnchor);
			caret.persistent = persistent;
			if (!managed)
			{
				if (caret.spriteMesh != null)
					((SpriteMesh)caret.spriteMesh).material = renderer.sharedMaterial;
			}
			else
			{
				if (manager != null)
				{
					caret.Managed = managed;
					manager.AddSprite(caret);
					caret.SetDrawLayer(drawLayer + 1);	// Caret should be drawn in front of the field graphic
				}
				else
					Debug.LogError("Sprite on object \"" + name + "\" not assigned to a SpriteManager!");
			}
			caret.autoResize = autoResize;
			if (pixelPerfect)
				caret.pixelPerfect = pixelPerfect;
			else
				caret.SetSize(caretSize.x, caretSize.y);

			if (states[1].spriteFrames.Length != 0)
			{
				caret.animations = new UVAnimation[1];
				caret.animations[0] = new UVAnimation();
				caret.animations[0].SetAnim(states[1], 0);
				caret.PlayAnim(0, 0);
			}
			caret.SetCamera(renderCamera);
			caret.Hide(true);
			transitions[1].list[0].MainSubject = caret.gameObject;

			PositionCaret();

			if (container != null)
				container.AddChild(caret.gameObject);
		}

		cachedPos = transform.position;
		cachedRot = transform.rotation;
		cachedScale = transform.lossyScale;
		CalcClippingRect();
	}