コード例 #1
0
ファイル: FXMakerEditor.cs プロジェクト: linbozhang/ThrowCoin
    protected bool DrawTrimTexture(Rect drawRect, bool bSelEnable, Material srcMat, NcSpriteFactory ncSpriteFactory, int nSelFactoryIndex, int nSelFrameIndex, bool bRotateRight, out int nClickFactoryIndex, out int nClickFrameIndex)
    {
//		FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);
        Texture srcTex = srcMat.mainTexture;

        GUI.DrawTexture(drawRect, srcTex, ScaleMode.StretchToFill, true);

        Event ev = Event.current;

        for (int n = 0; n < ncSpriteFactory.GetSpriteNodeCount(); n++)
        {
            NcSpriteFactory.NcSpriteNode ncSpriteNode = ncSpriteFactory.GetSpriteNode(n);
            if (ncSpriteNode.IsEmptyTexture())
            {
                continue;
            }

            for (int fc = 0; fc < ncSpriteNode.m_nFrameCount; fc++)
            {
                Color color;
                Rect  uvRect = ncSpriteFactory.GetSpriteUvRect(n, fc);
                // draw indexRect
                Rect currRect = new Rect(drawRect.x + uvRect.xMin * drawRect.width, drawRect.y + (1 - uvRect.yMin - uvRect.height) * drawRect.height, uvRect.width * drawRect.width, uvRect.height * drawRect.height);
                if (nSelFactoryIndex == n)
                {
                    color = (nSelFrameIndex == fc ? Color.green : Color.red);
                }
                else
                {
                    color = Color.yellow;
                }
                NgGUIDraw.DrawBox(FXMakerLayout.GetOffsetRect(currRect, 0), color, 1, false);

                // Change selIndex
                if (bSelEnable && (ev.type == EventType.MouseDown) && currRect.Contains(ev.mousePosition))
                {
//					m_Sel.SetSpriteFactoryIndex(n, fc, false);
                    nClickFactoryIndex = n;
                    nClickFrameIndex   = fc;
                    // Rotate
                    if (bRotateRight && ev.button == 1)
                    {
                        (target as NcEffectBehaviour).transform.Rotate(0, 180, 0);
                    }
                    Repaint();
                    return(true);
                }
            }
        }
        nClickFactoryIndex = 0;
        nClickFrameIndex   = 0;
        return(false);
    }
コード例 #2
0
	protected bool DrawTrimTexture(Rect drawRect, bool bSelEnable, Material srcMat, NcSpriteFactory ncSpriteFactory, int nSelFactoryIndex, int nSelFrameIndex, bool bRotateRight, out int nClickFactoryIndex, out int nClickFrameIndex)
	{
//		FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);
		Texture srcTex = srcMat.mainTexture;
		GUI.DrawTexture(drawRect, srcTex, ScaleMode.StretchToFill, true);

		Event	ev	= Event.current;

		for (int n = 0; n < ncSpriteFactory.GetSpriteNodeCount(); n++)
		{
			NcSpriteFactory.NcSpriteNode	ncSpriteNode = ncSpriteFactory.GetSpriteNode(n);
			for (int fc = 0; fc < ncSpriteNode.m_nFrameCount; fc++)
			{
				Color	color;
				Rect	uvRect	= ncSpriteFactory.GetSpriteUvRect(n, fc);
				// draw indexRect
				Rect currRect = new Rect(drawRect.x+uvRect.xMin*drawRect.width, drawRect.y+(1-uvRect.yMin-uvRect.height)*drawRect.height, uvRect.width*drawRect.width, uvRect.height*drawRect.height);
				if (nSelFactoryIndex == n)
				{
					color = (nSelFrameIndex == fc ? Color.green : Color.red);
				} else {
					color = Color.yellow;
				}
				NgGUIDraw.DrawBox(FXMakerLayout.GetOffsetRect(currRect, 0), color, 1, false);

				// Change selIndex
				if (bSelEnable && (ev.type == EventType.MouseDown) && currRect.Contains(ev.mousePosition))
				{
//					m_Sel.SetSpriteFactoryIndex(n, fc, false);
					nClickFactoryIndex	= n;
					nClickFrameIndex	= fc;
					// Rotate
					if (bRotateRight && ev.button == 1)
						(target as NcEffectBehaviour).transform.Rotate(0, 180, 0);
					Repaint();
					return true;
				}
			}
		}
		nClickFactoryIndex	= 0;
		nClickFrameIndex	= 0;
		return false;
	}