Ejemplo n.º 1
0
    //-----------------------------------------------------
    void Start()
    {
        m_bgImg = GameObject.Find("Background/backgroundImage");
        m_guiTexRef = m_bgImg.GetComponent<GUITexture>();

        m_baseTexture = null;
        //		if(m_baseTexture == null)
        //			m_baseTexture = (Texture)Resources.Load("mask/eraser_baseImg256");

        DeleteSubImages();
        CreateSubImages(m_subDivCount);
        //        m_childImgs = new Texture2D[m_subDivCount*m_subDivCount];

        m_erasedZones = new LinkedList<MaskedZone>();
        m_undoedZones = new Stack<MaskedZone>();
        m_backupZones = new List<MaskedZone>();

        //        m_merged = false;

        m_zoneToUpdate      = null;
        m_added             = false;

        m_offsetx = 0;
        m_offsety = 0;

        if(m_tool == GUIEditTools.EditTool.None)        // Si outil non initialisé, utiliser la gomme par défaut
            m_tool = GUIEditTools.EditTool.Eraser;

        //        m_baseTexture = new Texture2D(1024/m_subDivCount, 768/m_subDivCount);
        //        Color pixCol = new Color(0, 0, 0, 0);
        //        for(int x=0; x<m_baseTexture.width; x++)
        //        {
        //            for(int y=0; y<m_baseTexture.height; y++)
        //                ((Texture2D)m_baseTexture).SetPixel(x, y, pixCol);
        //        }
    }
Ejemplo n.º 2
0
    //-----------------------------------------------------
    void Start()
    {
        GameObject GUITexLoupe = GameObject.Find("Background/loupe/GUITexLoupe");
        _loupeGUI = GUITexLoupe.GetComponent<LoupeGUI>();
        if(_loupeGUI!=null)
            _loupeGUI.SetInvert(m_invert);
        _GUIMenuMain = GameObject.Find("MainScene").GetComponent<GUIMenuMain>();
        base.StartMouseTool();

        if(m_grassNode == null)   Debug.LogError(DEBUGTAG+"Grass Node" +PC.MISSING_REF);
        if(m_eraserNode == null)  Debug.LogError(DEBUGTAG+"Eraser Node"+PC.MISSING_REF);
        if(m_mainCam == null)     Debug.LogError(DEBUGTAG+"Main Camera"+PC.MISSING_REF);
        if(m_mainScene == null)   Debug.LogError(DEBUGTAG+"Main Scene" +PC.MISSING_REF);
        if(m_style == null)       Debug.LogError(DEBUGTAG+"GUI style " +PC.MISSING_REF);

        m_pleaseWaitUI = m_mainScene.GetComponent<PleaseWaitUI>();
        if(m_pleaseWaitUI == null) Debug.LogError("Script PleaseWaitUI non trouve");

        //m_guiZones = new List<Rect>(); // initialisation dans AddGuiZone() car Start est appelé après
        // m_cancelButtonRect =          // de même pour m_cancelButtonRect

        m_lastClickTime  = 0;
        m_clicked        = false;

        m_loupeActive    = false;
        m_loupeClickTime = 0;
        m_loupeTex       = new Texture2D(64, 64, TextureFormat.RGB24, false);
        m_loupeGUI       = GUITexLoupe.GetComponent<GUITexture>();
        m_loupeRenderTex = null;
        m_loupeGUI.texture = m_loupeTex;
        //        m_loupeCam.targetTexture = m_loupeRenderTex;

        m_stickBd        = 16;

        //        m_stickX        = -1;
        //        m_stickY        = -1;

        // Outil à appeler après le remplissage du polygone, et éventuels paramètres
        m_tool          = (m_tool == GUIEditTools.EditTool.None)? GUIEditTools.EditTool.Eraser : m_tool; // On utilise la gomme par défaut

        // -- GUI --
        m_cancelRect = new Rect(0f, 0f, m_style.fixedWidth, m_style.fixedHeight);
        SetGUIrects();
        //        AddGuiZone(m_cancelRect);

        m_mainCam.GetComponent<Mode2D>().enabled = false;
        m_mainScene.GetComponent<HelpPanel>().enabled = false;
    }
Ejemplo n.º 3
0
 //-----------------------------------------------------
 // redimensionnement afin de créer une marge et donc un
 // mini espace de travail autour.
 // Trop compliqué donc abandonné pour l'instant.
 //    public void ResizeImages(float percent)
 //    {
 //        GUITexture child;
 //        Rect       pixIn;
 //        float      subSections = Mathf.Sqrt(transform.GetChildCount());
 //        
 //        for(int i=0; i<transform.GetChildCount(); i++)
 //        {
 //            child = transform.GetChild(i).guiTexture;
 //            pixIn = child.guiTexture.pixelInset;
 //            
 //            pixIn.x += func(i%subSections);
 //            pixIn.y += func2(i-pixIn.x*subSections);
 //            pixIn.width -= 8;//pixIn.width*percent/100;
 //            pixIn.height -= 6;//pixIn.height*percent/100;
 //            
 //            child.guiTexture.pixelInset = pixIn;
 //        }
 //    } // ResizeImages();
 //    
 //    private int func(float x)
 //    {
 //        if(x == 0)
 //            return 16;
 //        else if(x == 1)
 //            return 8;
 //        else if(x == 2)
 //            return 0;
 //        else if(x==3)
 //            return -8;
 //        else
 //            return 0;
 //    }
 //    
 //    private int func2(float x)
 //    {
 //        if(x == 0)
 //            return -6;
 //        else if(x == 1)
 //            return 0;
 //        else if(x == 2)
 //            return 6;
 //        else if(x==3)
 //            return 12;
 //        else
 //            return 0;
 //    }
 //    
 //    //-----------------------------------------------------
 //    public void ResetImages()
 //    {
 //        GUITexture child;
 //        Rect       pixIn;
 //        float      subSections = Mathf.Sqrt(transform.GetChildCount());
 //        float      w = m_guiTexRef.pixelInset.width/transform.GetChildCount();
 //        float      h = m_guiTexRef.pixelInset.height/transform.GetChildCount();
 //        
 //        for(int i=0; i<transform.GetChildCount(); i++)
 //        {
 //            child = transform.GetChild(i).guiTexture;
 //            pixIn = child.guiTexture.pixelInset;
 //            
 //            pixIn.x = i%subSections * w;
 //            pixIn.y = i-i%subSections*subSections * h;
 //            pixIn.width = w;
 //            pixIn.height = h;
 //            
 //            child.guiTexture.pixelInset = pixIn;
 //        }
 //    }
 //-----------------------------------------------------
 public void SetTool(GUIEditTools.EditTool newTool)
 {
     m_tool = newTool;
 }
Ejemplo n.º 4
0
 //-----------------------------------------------------
 public void SetTool(GUIEditTools.EditTool tool)
 {
     m_tool = tool;
 }