Exemplo n.º 1
0
 void OnGUI()
 {
     TexMixUtil.mMixLvl = EditorGUILayout.IntField("Edit Lvl:", TexMixUtil.mMixLvl);
     TexMixUtil.mMixLvl = Mathf.Clamp(TexMixUtil.mMixLvl, 0, 3);
     TexMixUtil.mbErase = EditorGUILayout.Toggle("Erase", TexMixUtil.mbErase);
     TexMixUtil.mfValue = EditorGUILayout.Slider("Force", TexMixUtil.mfValue, 0.0f, 1.0f);
     GUILayout.BeginHorizontal();
     GUILayout.Label(TexMixBrush.GetTexObj(), GUILayout.Width(64.0f), GUILayout.Height(64.0f));
     GUILayout.Space(80.0f);
     if (GUILayout.Button("Load    Brush", GUILayout.Width(100.0f)))
     {
         LoadBrushImage();
     }
     GUILayout.EndHorizontal();
 }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        if (mSelObj != null)
        {
            Vector3 vsize = mSelObj.GetComponent <Collider>().bounds.size;
            float   fu    = 1.0f / vsize.x;
            float   fv    = 1.0f / vsize.z;
            string  szScl = fu.ToString() + ", " + fv.ToString();
            EditorGUILayout.TextField("Bound Box:", vsize.ToString());
            EditorGUILayout.TextField("UVScale:", szScl);
        }

        TexMixUtil.mMixLvl = EditorGUILayout.IntField("Edit Lvl:", TexMixUtil.mMixLvl);
        TexMixUtil.mMixLvl = Mathf.Clamp(TexMixUtil.mMixLvl, 0, 3);
        TexMixUtil.mbErase = EditorGUILayout.Toggle("Erase", TexMixUtil.mbErase);
        TexMixUtil.mfValue = EditorGUILayout.Slider("Force", TexMixUtil.mfValue, 0.0f, 1.0f);
        GUILayout.BeginHorizontal();
        GUILayout.Label(TexMixBrush.GetTexObj(), GUILayout.Width(64.0f), GUILayout.Height(64.0f));
        GUILayout.Space(75.0f);
        if (GUILayout.Button("Load  Brush", GUILayout.Width(100.0f)))
        {
            LoadBrushImage();
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Space(12.0f);
        if (GUILayout.Button("Undo", GUILayout.Width(80.0f)))
        {
            TexMixUtil.NtfExcuteUndo();
        }
        GUILayout.Space(12.0f);
        if (GUILayout.Button("Redo", GUILayout.Width(80.0f)))
        {
            TexMixUtil.NtfExcuteRedo();
        }
        GUILayout.Space(12.0f);
        if (GUILayout.Button("Clear", GUILayout.Width(80.0f)))
        {
            TexMixUtil.NtfClearCurLvl(TexMixUtil.mMixLvl);
        }
        GUILayout.EndHorizontal();
        SceneView.RepaintAll();                 // Repaint SceneView
    }
Exemplo n.º 3
0
    // 淇?敼娣峰悎姣斾緥鍥诫 杈撳叆鐐瑰嚮鐐箄v, 涔嬪悗鏍规嵁閰嶇疆澶勭悊
    static public bool NtfModifyTexture(Vector2 uv)
    {
        if (mTexObj == null)
        {
            return(false);
        }

        if (!TexMixBrush.IsBrushOK())
        {
            return(false);
        }
        Texture2D brushTex = TexMixBrush.GetTexObj();

        int mBrushW = brushTex.width / 2;
        int mBrushH = brushTex.height / 2;

        int cx = (int)(uv.x * mTexObj.width);
        int cy = (int)(uv.y * mTexObj.height);

        int xMin = Mathf.Max(0, cx - mBrushW);
        int yMin = Mathf.Max(0, cy - mBrushH);

        int xMax = Mathf.Min(mTexObj.width - 1, cx + mBrushW);
        int yMax = Mathf.Min(mTexObj.height - 1, cy + mBrushH);

        int   myW  = xMax - xMin;
        int   myH  = yMax - yMin;
        float fVal = mbErase ? -mfValue : mfValue;

        Color[] cold = mTexObj.GetPixels(xMin, yMin, myW, myH, 0);

        if (cold.Length <= 0)
        {
            return(false);
        }

        TexMixCMD cmd = new TexMixCMD();

        cmd.mMinX = xMin;
        cmd.mMinY = yMin;
        cmd.mRctW = myW;
        cmd.mRctH = myH;
        cmd.mBack = new Color[cold.Length];
        cmd.mNext = new Color[cold.Length];

        Color[] cols = TexMixBrush.GetColors();
        for (int i = 0; i < cold.Length; ++i)
        {
            cmd.mBack[i].r = cold[i].r;
            cmd.mBack[i].g = cold[i].g;
            cmd.mBack[i].b = cold[i].b;
            cmd.mBack[i].a = cold[i].a;
            //Debug.Log(cmd.mBack[i]);
            float fval = cold[i][mMixLvl] + cols[i].a * fVal;
            cold[i][mMixLvl] = Mathf.Clamp(fval, 0.0f, 1.0f);

            cmd.mNext[i].r = cold[i].r;
            cmd.mNext[i].g = cold[i].g;
            cmd.mNext[i].b = cold[i].b;
            cmd.mNext[i].a = cold[i].a;
        }

        mUndoMng.NtfAddUndoCmd(cmd);

        mTexObj.SetPixels(xMin, yMin, myW, myH, cold, 0);
        mTexObj.Apply();
        mTarget.GetComponent <Renderer>().material.SetTexture("_TexMix", mTexObj);
        return(true);
    }