Exemple #1
0
    // Mouse Down Event
    bool OnMouseDownEvent()
    {
        Event evn = Event.current;

        if (!evn.isMouse || (evn.type != EventType.MouseDown))
        {
            return(false);
        }
        mLastClk = evn.mousePosition;
        if (!IsEditEnable())
        {
            return(true);
        }
        if (evn.button == 0)            // Left Button
        {
        }
        else if (evn.button == 1)               // Right Button
        {
            RaycastHit hit;
            if (EditorUtil.OnHitTest(out hit))
            {
                //EditorUtil.NtfLogHitMsg("Hit", hit);
                TexMixUtil.BeginCMD();
                //TexMixUtil.NtfModifyTexture(hit.textureCoord);
                TexMixUtil.NtfModifyTexture(hit.point);
                TexMixUtil.EndCMD();
            }
        }
        return(true);
    }
Exemple #2
0
    static void Execute()
    {
#if !UNITY_STANDALONE_WIN
        Debug.LogError("Only WORK on Windows Platform: file--> Build Setting --> PC, Mac.. --> Windows");
#endif
        GameObject obj = EditorUtil.GetEditTarget();
        //if(obj != mSelObj)
        {
            mSelObj = obj;
            TexMixBrush.NtfCreateBrush("Brushes/brush_14");
            if (TexMixUtil.NtfAttachTarget(mSelObj))
            {
                mCurOp = TEOM_ENABLE;
            }
        }
    }
Exemple #3
0
    // Mouse Move Event
    bool OnMouseMoveEvent()
    {
        Event evn = Event.current;

        if (!evn.isMouse || (evn.type != EventType.MouseMove))
        {
            return(false);
        }
        if (mLastClk == evn.mousePosition)
        {
            return(true);
        }
        mLastClk = evn.mousePosition;


        if (!IsEditEnable())
        {
            return(true);
        }

        //if(!evn.shift) return true;
        //if(!evn.control) return true;

        if (!evn.control)
        {
            TexMixUtil.EndCMD();
        }

        RaycastHit hit;

        if (EditorUtil.OnHitTest(out hit))
        {
            mEditor.mDrawPos = hit.point;

            if (evn.control)
            {
                TexMixUtil.BeginCMD();
                //TexMixUtil.NtfModifyTexture(hit.textureCoord);
                TexMixUtil.NtfModifyTexture(hit.point);
            }
            //EditorUtil.NtfLogHitMsg("MousMv", hit);
        }
        return(true);
    }
Exemple #4
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
    }
Exemple #5
0
    static void SaveBlendTexture()
    {
        if (mSelObj == null)
        {
            EditorUtility.DisplayDialog("Save Texture", "No Texture!", "Ok");
            return;
        }

        string szFl  = TexMixUtil.GetTexFile();        //GetTexName();
        string szDir = Application.dataPath + "/";
        string szFNm = "";

        if (szFl.Length > 0)
        {
            szDir = Path.GetDirectoryName(szFl);
            szFNm = Path.GetFileName(szFl);
        }
        string file = EditorUtility.SaveFilePanel("Save Texture", szDir, szFNm, "png");

        TexMixUtil.NtfSaveTexture(file);
    }