コード例 #1
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 = GetComponent <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);
        }

        if (autoResize)
        {
            // Force start and resize since it would not have
            // taken effect earlier since the UVs were not
            // yet initialized:
            caret.Start();
            caret.SetSize(caretSize.x, caretSize.y);
        }
    }
コード例 #2
0
ファイル: UITextField.cs プロジェクト: adahera222/properme
	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
				ScreenLog.AddMessage("Sprite on object \"" + name + "\" not assigned to a SpriteManager!", ScreenLogType.Error);
		}
		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);

		if (autoResize)
		{
			// Force start and resize since it would not have
			// taken effect earlier since the UVs were not
			// yet initialized:
			caret.Start();
			caret.SetSize(caretSize.x, caretSize.y);
		}
	}