Example #1
0
    void Start()
    {
        button = GetComponent<GUITexture>();
        button.color = inactiveColor;

        VirtualInput.AddButton(buttonName);
    }
Example #2
0
 void MatchPickup()
 {
     haveMatches = true;
     AudioSource.PlayClipAtPoint(collectSound, transform.position);
     GUITexture matchHUD = Instantiate(matchGUIprefab, new Vector3(0.15f, 0.1f, 0), transform.rotation) as GUITexture;
     matchGUI = matchHUD;
 }
    // Use this for initialization
    void Start()
    {
        // Cache this component at startup instead of looking up every frame
        gui = gameObject.guiTexture;
        gui.pixelInset = new Rect(gui.pixelInset.x * Screen.width / 1280, gui.pixelInset.y * Screen.width / 1280, gui.pixelInset.width * Screen.width / 1280, gui.pixelInset.height * Screen.width / 1280);
        // Store the default rect for the gui, so we can snap back to it
        defaultRect = gui.pixelInset;

        //defaultRect= new Rect(
        defaultRect.x += transform.position.x * Screen.width;// + gui.pixelInset.x; // -  Screen.width * 0.5;
        defaultRect.y += transform.position.y * Screen.height;// - Screen.height * 0.5;

        transform.position = new Vector3 (0.0f, 0.0f, transform.position.z);

        if (touchPad) {
            // If a texture has been assigned, then use the rect ferom the gui as our touchZone
            if (gui.texture)
                touchZone = defaultRect;
        } else {
            // This is an offset for touch input to match with the top left
            // corner of the GUI
            guiTouchOffset = new Vector2 (defaultRect.width * 0.5f, defaultRect.height * 0.5f);

            // Cache the center of the GUI, since it doesn't change
            guiCenter = new Vector2 (defaultRect.x + guiTouchOffset.x, defaultRect.y + guiTouchOffset.y);

            // Let's build the GUI boundary, so we can clamp joystick movement
            guiBoundary.min.x = defaultRect.x - guiTouchOffset.x;
            guiBoundary.max.x = defaultRect.x + guiTouchOffset.x;
            guiBoundary.min.y = defaultRect.y - guiTouchOffset.y;
            guiBoundary.max.y = defaultRect.y + guiTouchOffset.y;
        }
    }
Example #4
0
 void Awake()
 {
     _GUITexture = GetComponent<GUITexture>();
     float width = _GUITexture.pixelInset.width * Screen.width / 752;
     float height = _GUITexture.pixelInset.height * Screen.height / 423;
     _GUITexture.pixelInset = new Rect(-width * 0.5F, -height * 0.5F, width, height);
 }
Example #5
0
	void Awake ()
	{
		_transform = transform;
		_gui = GetComponent<GUITexture> ();
		_gui.enabled = false;
		_defaultRect = _gui.pixelInset;
		_defaultRect.x += _transform.position.x * Screen.width;// + gui.pixelInset.x; // -  Screen.width * 0.5;
		_defaultRect.y += _transform.position.y * Screen.height;// - Screen.height * 0.5;
		_transform.position = Vector3.zero;
		if (touchPad) {
			// If a texture has been assigned, then use the rect ferom the gui as our touchZone
			if (_gui.texture)
				touchZone = _defaultRect;
		} else {
			_guiTouchOffset.x = _defaultRect.width * 0.5f;
			_guiTouchOffset.y = _defaultRect.height * 0.5f;
			
			// Cache the center of the GUI, since it doesn't change
			_guiCenter.x = _defaultRect.x + _guiTouchOffset.x;
			_guiCenter.y = _defaultRect.y + _guiTouchOffset.y;
			
			// Let's build the GUI boundary, so we can clamp joystick movement
			_guiBoundary.min.x = _defaultRect.x - _guiTouchOffset.x / xBounds;
			_guiBoundary.max.x = _defaultRect.x + _guiTouchOffset.x / xBounds;
			_guiBoundary.min.y = _defaultRect.y - _guiTouchOffset.y / yBounds;
			_guiBoundary.max.y = _defaultRect.y + _guiTouchOffset.y / yBounds;
		}
		ResetJoystick ();
	}
 //
 private void Awake()
 {
     if (divvyFactor == 0) {
         divvyFactor = 1;
     }
     button = gameObject.AddComponent ("GUITexture") as GUITexture;
     button.texture = button2D;
     button.color = inactiveColor;
     transform.position = new Vector3 (0f, 0f, transform.position.z);
     //Debug.Log ("sw = " + Screen.width + "  sh = " + Screen.height);
     button.pixelInset = new Rect (GetPixelScale (transform.position.x, Screen.width), GetPixelScale (transform.position.y, Screen.height), (Screen.width / divvyFactor), (Screen.width / divvyFactor));
     //Debug.Log ("1) " + button.pixelInset);
     if (button.pixelInset.x < (Screen.width / 3) + 25 && button.pixelInset.y < (Screen.height / 3) + 25) {
         button.pixelInset = new Rect ((Screen.width / 3) + 410, -117, (Screen.width / divvyFactor), (Screen.width / divvyFactor));
         //Debug.Log ("2) " + button.pixelInset);
     }
     if (button.pixelInset.x > Screen.width - (button.pixelInset.width + 25) && button.pixelInset.y > Screen.height - (button.pixelInset.height + 25)) {
         button.pixelInset = new Rect (Screen.width - (button.pixelInset.width + 25), Screen.height - (button.pixelInset.height + 25), (Screen.width / divvyFactor), (Screen.width / divvyFactor));
         //Debug.Log ("3) " + button.pixelInset);
     }
     fingerID = -1;
     lastID = -1;
     tapTimer = 0;
     enable = true;
     VBRsingleTap = false;
     VBRdoubleTap = false;
     objPlayer = (GameObject)GameObject.FindWithTag ("Player");
 }
	// Use this for initialization
	void Start () 
	{
		m_StartTime = Time.timeSinceLevelLoad ;
		m_EndTime = m_StartTime + m_ElapsedSec ;
		m_TargetGUITexture = this.guiTexture ;
		m_OrgRect = new Rect( m_TargetGUITexture.pixelInset ) ;
	}
Example #8
0
    public Field(string fieldName, int player)
    {
        CustomError ce = new CustomError("Field", "constructor");
        this.cells = new Cell[this.byX, this.byY];

        for (int i = 0; i < this.byX; i++)
        {
            for (int j = 0; j < this.byY; j++)
            {
                this.cells[i, j] = new Cell(i, j);
            }
        }

        Morpher mphr = GameObject.Find("Morpher").GetComponent<Morpher>();
        mphr.InstAField(fieldName, ref this.realObjectReference);
        if (player == 1)
        {
            this.crossHair = mphr.InstACross().GetComponent<GUITexture>();
            this.allocatingShips = true;
        }
        else
        {
            this.allocatingShips = false;
        }

        EventManager.OnResize += this.ResizeAfterCreate;
    }
    void FadeToWhite()
    {
        if (startFade)
        {
            if (whiteBackground == null)
            {
                whiteBackground = (GUITexture)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().whiteBackground);
                whiteBackground.name = "WhiteBackground";

                whiteBackground.gameObject.AddComponent("ResizeGUITexture");
                (whiteBackground.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = whiteBackground.guiTexture;
                (whiteBackground.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();
                SceneManager.Instance.scene.DestroySomeInterfaceElements();
            }

            if (whiteBackground.color.a < 0.5f)
                whiteBackground.color = new Color(
                    whiteBackground.color.r,
                    whiteBackground.color.g,
                    whiteBackground.color.b,
                    whiteBackground.color.a + fadeConst * Time.deltaTime);
            else
            {
                Destroy(whiteBackground);
                whiteBackground = null;
                SceneManager.Instance.scene.CloseScene();
                SceneManager.Instance.ChangeLevelCampaignMode(level);
            }
        }
    }
	// Use this for initialization
	void Start () 
	{
		m_StartTime = Time.timeSinceLevelLoad ;
		m_EndTime = m_StartTime + m_ElapsedSec ;
		m_TargetGUITexture = this.guiTexture ;
		m_OrgColor = m_TargetGUITexture.color ;
	}
Example #11
0
 public Field()
 {
     CustomError ce = new CustomError("Field", "constructor");
     this.cells = new Cell[this.byX, this.byY];
     GUITexture gt = new GUITexture();
     Jobster jb = GameObject.Find("jobster").GetComponent<Jobster>();
 }
Example #12
0
    // Use this for initialization
    void Start()
    {
        healthObject = GameObject.Find("GUI/g_health");
        healthTexture = healthObject.GetComponent<GUITexture>();

        healthValue = 100;
    }
Example #13
0
    void Awake()
    {
        #if !(UNITY_EDITOR)

        _gui_text = GetComponent<GUIText> ();
        _gui_texture = GetComponent<GUITexture> ();
        screenX = Screen.width;
        screenY = Screen.height;
        scaleX = screenX / 960;
        scaleY = screenY / 640;

        if (_gui_texture != null) {
            _guiWidth = _gui_texture.pixelInset.width;
            _guiHeight = _gui_texture.pixelInset.height;

            _guiWidth *= scaleX;
            _guiHeight *= scaleY;
        }

        if(_gui_text != null)
        {
            _gui_text.fontSize = (int)(edit_fontSize * (scaleX));
        }

        PositionSetting ();
        #endif
    }
 // Use this for initialization
 protected void Start()
 {
     texture = GetComponent<GUITexture>();
     texture.enabled = true;
     text = GetComponentInChildren<GUIText>();
     text.enabled = true;
 }
Example #15
0
 void Awake()
 {
     player = GameObject.FindWithTag("Flashlight");
     fader = (GameObject.Find("ScreenFader").GetComponent<GUITexture>()as GUITexture);
     fader.guiTexture.enabled = false;
     fader.guiTexture.pixelInset = new Rect(-5000, -5000, 10000, 10000);
 }
    public override void Start()
    {
        //-PLAYERAIRPLANE-------------------------------------------------------------------------//
        playerAirplane = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().PlayerAirplane);
        playerAirplane.name = "PlayerAirplane";

        // Setamos a o aviao como alvo da camera
        SmoothFollow.Instance.target = playerAirplane.transform;

        //-SET------------------------------------------------------------------------------------//
        Set = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().Set);
        Set.name = "Set";

        //-LIGHT----------------------------------------------------------------------------------//
        Light = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().Light);
        Light.name = "Light";

        //-INTERFACE-IN-GAME----------------------------------------------------------------------//
        interfaceInGame = (GUITexture)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().interfaceInGame);
        interfaceInGame.name = "InterfaceInGame";

        interfaceInGame.gameObject.AddComponent("ResizeGUITexture");
        (interfaceInGame.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = interfaceInGame.guiTexture;
        (interfaceInGame.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        (interfaceInGame.GetComponent("AirSpeedIndicator") as AirSpeedIndicator).playerAirplane = (this.playerAirplane.GetComponent("PlayerAirplane") as PlayerAirplane);
    }
Example #17
0
 // Use this for initialization
 void Start()
 {
     guiText = gameObject.GetComponent<GUIText>();
     textBackground = GameObject.Find("ScoreBackground").GetComponent<GUITexture>();
     mic = GameObject.Find ("Beat Detector").GetComponent<MicrophoneInput>();
     player = GameObject.Find ("Player").GetComponent<Movement>();
 }
Example #18
0
 public override void CloseScene()
 {
     Destroy(background.gameObject);
     Destroy(pressSpaceButton.gameObject);
     background = null;
     pressSpaceButton = null;
 }
Example #19
0
    protected void OnEnable()
    {
        CreateVirtualAxes();

        // Cache this component at startup instead of looking up every frame	
        gui = GetComponent<GUITexture>();

        if (gui != null)
        {
            // Store the default rect for the gui, so we can snap back to it
            defaultRect = gui.GetScreenRect();

            gui.pixelInset = defaultRect;
            transform.localScale = Vector3.zero;
        }

        transform.position = new Vector3(0.0f, 0.0f, transform.position.z);
        moveStick = true;
       
        TypeSpecificOnEnable();
       
        if (enumeratedJoysticks)
            return;
        // Collect all joysticks in the game, so we can relay finger latching messages
        joysticks = FindObjectsOfType<JoystickAbstract>();
        enumeratedJoysticks = true;
    }
Example #20
0
	public void Start()
	{
		back = GameObject.Find("ScorebarBack").GetComponent<GUITexture>();
		front = GameObject.Find("ScorebarFront").GetComponent<GUITexture>();
		mid = GameObject.Find("ScorebarMid").GetComponent<GUITexture>();
		decofront = GameObject.Find("ScorebarDecoFront").GetComponent<GUITexture>();
		
#if HORIZONTAL
		maxSize = front.pixelInset.width;
#else
		maxSize = front.pixelInset.height;
#endif
		
		factor = Screen.height / 480.0f;
		
		Rect rect = decofront.pixelInset;
		
#if HORIZONTAL
		rect.width *= factor;
#else
		rect.height *= factor;
#endif
		
		decofront.pixelInset = rect;
		
		currentLength = maxSize;
		actualLength = maxSize;
	}
 private void Awake()
 {
     Background = new GameObject("Background").AddComponent<GUITexture>();
     SplashScreen = new GameObject("SplashScreen").AddComponent<GUITexture>();
     Background.texture = BackgroundTexture;
     SplashScreen.texture = SplashScreenTexture;
 }
Example #22
0
	void Start() {
		// Find the GUI components
		GameObject go = GameObject.Find("ShotCounter");
		shotCounter = go.GetComponent<GUIText>();
		go = GameObject.Find("ShotRating");
		shotRating = go.GetComponent<GUIText>();
		go = GameObject.Find("_Check_64");
		checkMark = go.GetComponent<GUITexture>();
		go = GameObject.Find ("WhiteOut");
		whiteOut = go.GetComponent<GUITexture>();
		// Hide the checkMark and whiteOut
		checkMark.enabled = false;
		whiteOut.enabled = false;

		// Load all the shots from PlayerPrefs
		Shot.LoadShots();
		// If there were shots stored in PlayerPrefs
		if (Shot.shots.Count>0) {
			shotNum = 0;
			ResetPlayerShotsAndRatings();
			ShowShot(Shot.shots[shotNum]);
		}

		// Hide the cursor (Note: this doesn't work in the Unity Editor unless
		// the Game pane is set to Maximize on Play.)
		Screen.showCursor = false;

		camRectNormal = camera.rect;
	}
Example #23
0
    void Start()
    {
        //transform.position.x = 0;
        //transform.position.y = 0;
        gui = (GUITexture)GetComponent (typeof(GUITexture));
        defaultRect = gui.pixelInset;

        defaultRect.x += transform.position.x * Screen.width;// + gui.pixelInset.x; // -  Screen.width * 0.5;

        defaultRect.y += transform.position.y * Screen.height;// - Screen.height * 0.5;
        transform.position = Vector3.zero;
        if (touchPad) {
            // If a texture has been assigned, then use the rect ferom the gui as our touchZone
            if (gui.texture)
                touchZone = defaultRect;
        } else {
            guiTouchOffset.x = defaultRect.width * 0.5f;
            guiTouchOffset.y = defaultRect.height * 0.5f;
            // Cache the center of the GUI, since it doesn't change
            guiCenter.x = defaultRect.x + guiTouchOffset.x;
            guiCenter.y = defaultRect.y + guiTouchOffset.y;
            // Let's build the GUI boundary, so we can clamp joystick movement
            guiBoundary.min.x = defaultRect.x - guiTouchOffset.x;
            guiBoundary.max.x = defaultRect.x + guiTouchOffset.x;
            guiBoundary.min.y = defaultRect.y - guiTouchOffset.y;
            guiBoundary.max.y = defaultRect.y + guiTouchOffset.y;
        }
    }
 public ControlButton(GUITexture _gui, Texture _textureOn, Texture _textureOff)
 {
     // isPlayer = Application.platform == RuntimePlatform.OSXPlayer;
     gui = _gui;
     textureOn = _textureOn;
     textureOff = _textureOff;
 }
Example #25
0
    // Use this for initialization
    void Start()
    {
        // Cache this component at startup instßead of looking up every frame
        gui = GetComponent<GUITexture>();

        // Store the default rect for the gui, so we can snap back to it
        defaultRect = gui.pixelInset;

        defaultRect.x += transform.position.x * Screen.width;
        defaultRect.y += transform.position.y * Screen.height;

        //this.transform.position.x = 0.0f;
        //this.transform.position.y = 0.0f;
        transform.position = new Vector3(0.0f, 0.0f, 0.0f);

        // This is an offset for touch input to match with the top left
        // corner of the GUI
        guiTouchOffset.x = defaultRect.width * 0.5f;
        guiTouchOffset.y = defaultRect.height * 0.5f;

        // Cache the center of the GUI, since it doesn't change
        guiCenter.x = defaultRect.x + guiTouchOffset.x;
        guiCenter.y = defaultRect.y + guiTouchOffset.y;

        // Let's build the GUI boundary, so we can clamp joystick movement
        guiBoundary.min.x = defaultRect.x - guiTouchOffset.x;
        guiBoundary.max.x = defaultRect.x + guiTouchOffset.x;
        guiBoundary.min.y = defaultRect.y - guiTouchOffset.y;
        guiBoundary.max.y = defaultRect.y + guiTouchOffset.y;
    }
    //
    private void Awake()
    {
        gameObject.transform.localScale = new Vector3(0,0,0);

        gameObject.transform.position = new Vector3(0,0,999);

        if (Screen.width > Screen.height) {size = Screen.height;} else {size = Screen.width;} VJRvector = new Vector2(0,0);

        joystick = gameObject.AddComponent("GUITexture") as GUITexture;

        joystick.texture = joystick2D; joystick.color = inactiveColor;

        backOBJ = new GameObject("VJR-Joystick Back");

        backOBJ.transform.localScale = new Vector3(0,0,0);

        background = backOBJ.AddComponent("GUITexture") as GUITexture;

        background.texture = background2D; background.color = inactiveColor;

        fingerID = -1; lastID = -1; VJRdoubleTap = false; tapTimer = 0; length = 50;

        position = new Vector2((Screen.width/3)/2,(Screen.height/3)/2); origin = position;

        gotPosition = false; EnableJoystick(); enable = true;
    }
Example #27
0
	// Use this for initialization
	void Start () 
    {
	    for ( int i = 0; i < m_dialogue.Length; ++i )
        {
            m_dialogue[i].enabled = false;
        }

        //m_dialogue[m_currentDialogue].enabled = true;

        m_fadeRenderer = m_blackTextureObject.GetComponent<GUITexture>();
        m_textRenderer = m_dialogue[m_currentDialogue].GetComponent<GUIText>();
        m_textBackgroundRenderer = m_textBackground.GetComponent<GUITexture>();
        //m_textBackgroundColor = m_textBackgroundRenderer.color;

//         m_fadeScale.x = (float)(8000 / m_fadeRenderer.sprite.texture.width);
//         m_fadeScale.y = (float)(8000 / m_fadeRenderer.sprite.texture.height);
//         m_fadeScale.z = 1.0f;

        //m_blackTextureObject.transform.localScale = m_fadeScale;
        m_textBackgroundRenderer.color = Color.clear;
        m_textBackgroundRenderer.enabled = true;
        m_fadeRenderer.color = Color.black;
        m_fadeRenderer.enabled = true;
        m_textRenderer.color = Color.clear;
	}
Example #28
0
    // Use this for initialization
    void Start()
    {
        _display = gameObject.GetComponent<GUITexture>();

        _maxBarLength = (int)_display.pixelInset.width;
        OnEnable();
    }
Example #29
0
    // Use this for initialization
    void Start()
    {
        _vitalBar = gameObject.GetComponent<GUITexture>();
        _maxBarLength = _vitalBar.pixelInset.width; //set the bar length to the texture width

        OnEnable();
    }
Example #30
0
	// Use this for initialization
	void Start () {
		instance = this;

		player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();

		GameObject mapCameraObj = GameObject.FindGameObjectWithTag ("mapCamera");
		if(mapCameraObj != null){
			mapCamera = mapCameraObj.GetComponent<Camera>();
			mapCamera.enabled = false;
		}

		GUITexture[] hudGUIs = GetComponentsInChildren<GUITexture>();
		powerImg = hudGUIs[0];
		crosshairImg = hudGUIs[1];
		matchImg = hudGUIs[2];
		if (mapCamera != null) {
			gunCrosshairImg = hudGUIs [3];
		}

		GUIText[] guiText = GetComponentsInChildren<GUIText>();
		hintsText = guiText[0];

		if (mapCamera != null) {
			hpText = guiText [1];
			bulletText = guiText [2];
			hiScoreText = guiText [3];
			scoreText = guiText [4];
		}

		HideCursor();
		SetHiScore(hiScore);
	}
Example #31
0
    void Awake()
    {
        //sceneTransition = transform.GetComponent<SceneTransition>();
        TrainerAudio = transform.GetComponent <AudioSource>();

        cancel = transform.Find("Cancel").GetComponent <GUITexture>();

        screens = transform.Find("Screens");

        card = screens.Find("Card").GetComponent <GUITexture>();

        IDnoBox             = card.transform.Find("IDno").GetComponent <GUITexture>();
        IDnoText            = IDnoBox.transform.Find("IDnoText").GetComponent <GUIText>();
        IDnoTextShadow      = IDnoBox.transform.Find("IDnoTextShadow").GetComponent <GUIText>();
        IDnoData            = IDnoBox.transform.Find("IDnoData").GetComponent <GUIText>();
        IDnoDataShadow      = IDnoBox.transform.Find("IDnoDataShadow").GetComponent <GUIText>();
        nameBox             = card.transform.Find("NameBox").GetComponent <GUITexture>();
        nameText            = nameBox.transform.Find("NameText").GetComponent <GUIText>();
        nameTextShadow      = nameBox.transform.Find("NameTextShadow").GetComponent <GUIText>();
        nameData            = nameBox.transform.Find("NameData").GetComponent <GUIText>();
        nameDataShadow      = nameBox.transform.Find("NameDataShadow").GetComponent <GUIText>();
        picture             = card.transform.Find("Picture").GetComponent <GUITexture>();
        moneyBox            = card.transform.Find("Money").GetComponent <GUITexture>();
        moneyText           = moneyBox.transform.Find("MoneyText").GetComponent <GUIText>();
        moneyTextShadow     = moneyBox.transform.Find("MoneyTextShadow").GetComponent <GUIText>();
        moneyData           = moneyBox.transform.Find("MoneyData").GetComponent <GUIText>();
        moneyDataShadow     = moneyBox.transform.Find("MoneyDataShadow").GetComponent <GUIText>();
        pokedexBox          = card.transform.Find("Pokedex").GetComponent <GUITexture>();
        pokedexText         = pokedexBox.transform.Find("PokedexText").GetComponent <GUIText>();
        pokedexTextShadow   = pokedexBox.transform.Find("PokedexTextShadow").GetComponent <GUIText>();
        pokedexData         = pokedexBox.transform.Find("PokedexData").GetComponent <GUIText>();
        pokedexDataShadow   = pokedexBox.transform.Find("PokedexDataShadow").GetComponent <GUIText>();
        scoreBox            = card.transform.Find("Score").GetComponent <GUITexture>();
        scoreText           = scoreBox.transform.Find("ScoreText").GetComponent <GUIText>();
        scoreTextShadow     = scoreBox.transform.Find("ScoreTextShadow").GetComponent <GUIText>();
        scoreData           = scoreBox.transform.Find("ScoreData").GetComponent <GUIText>();
        scoreDataShadow     = scoreBox.transform.Find("ScoreDataShadow").GetComponent <GUIText>();
        timeBox             = card.transform.Find("Time").GetComponent <GUITexture>();
        timeText            = timeBox.transform.Find("TimeText").GetComponent <GUIText>();
        timeTextShadow      = timeText.transform.Find("TimeTextShadow").GetComponent <GUIText>();
        timeHour            = timeBox.transform.Find("TimeHour").GetComponent <GUIText>();
        timeHourShadow      = timeHour.transform.Find("TimeHourShadow").GetComponent <GUIText>();
        timeColon           = timeBox.transform.Find("TimeColon").GetComponent <GUIText>();
        timeColonShadow     = timeColon.transform.Find("TimeColonShadow").GetComponent <GUIText>();
        timeMinute          = timeBox.transform.Find("TimeMinute").GetComponent <GUIText>();
        timeMinuteShadow    = timeMinute.transform.Find("TimeMinuteShadow").GetComponent <GUIText>();
        adventureBox        = card.transform.Find("Adventure").GetComponent <GUITexture>();
        adventureText       = adventureBox.transform.Find("AdventureText").GetComponent <GUIText>();
        adventureTextShadow = adventureBox.transform.Find("AdventureTextShadow").GetComponent <GUIText>();
        adventureData       = adventureBox.transform.Find("AdventureData").GetComponent <GUIText>();
        adventureDataShadow = adventureBox.transform.Find("AdventureDataShadow").GetComponent <GUIText>();

        badgeBox = screens.Find("BadgeBox").GetComponent <GUITexture>();

        badgeBoxLid        = badgeBox.transform.Find("BadgeBoxLid").GetComponent <GUITexture>();
        GLPictureBox       = badgeBox.transform.Find("GLPictureBox").GetComponent <GUITexture>();
        GLPicture          = GLPictureBox.transform.Find("Picture").GetComponent <GUITexture>();
        GLNameBox          = badgeBox.transform.Find("GLNameBox").GetComponent <GUITexture>();
        GLNameData         = GLNameBox.transform.Find("NameData").GetComponent <GUIText>();
        GLNameDataShadow   = GLNameBox.transform.Find("NameDataShadow").GetComponent <GUIText>();
        GLTypeBox          = badgeBox.transform.Find("GLTypeBox").GetComponent <GUITexture>();
        GLType             = GLTypeBox.transform.Find("Type").GetComponent <GUITexture>();
        GLBeatenBox        = badgeBox.transform.Find("GLBeatenBox").GetComponent <GUITexture>();
        GLBeatenText       = GLBeatenBox.transform.Find("BeatenText").GetComponent <GUIText>();
        GLBeatenTextShadow = GLBeatenBox.transform.Find("BeatenTextShadow").GetComponent <GUIText>();
        GLBeatenData       = GLBeatenBox.transform.Find("BeatenData").GetComponent <GUIText>();
        GLBeatenDataShadow = GLBeatenBox.transform.Find("BeatenDataShadow").GetComponent <GUIText>();

        Transform badgesObject = badgeBox.transform.Find("Badges");

        badges[0]  = badgesObject.Find("Badge0").GetComponent <GUITexture>();
        badges[1]  = badgesObject.Find("Badge1").GetComponent <GUITexture>();
        badges[2]  = badgesObject.Find("Badge2").GetComponent <GUITexture>();
        badges[3]  = badgesObject.Find("Badge3").GetComponent <GUITexture>();
        badges[4]  = badgesObject.Find("Badge4").GetComponent <GUITexture>();
        badges[5]  = badgesObject.Find("Badge5").GetComponent <GUITexture>();
        badges[6]  = badgesObject.Find("Badge6").GetComponent <GUITexture>();
        badges[7]  = badgesObject.Find("Badge7").GetComponent <GUITexture>();
        badges[8]  = badgesObject.Find("Badge8").GetComponent <GUITexture>();
        badges[9]  = badgesObject.Find("Badge9").GetComponent <GUITexture>();
        badges[10] = badgesObject.Find("Badge10").GetComponent <GUITexture>();
        badges[11] = badgesObject.Find("Badge11").GetComponent <GUITexture>();
        badgeSel   = badgesObject.Find("BadgeSel").GetComponent <GUITexture>();

        background = transform.Find("background").GetComponent <GUITexture>();
    }
 // Use this for initialization
 void Start()
 {
     theHealthBar = gameObject.GetComponent <GUITexture>();
 }
        /// <summary>
        /// Sets a scene object whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="so">Scene object to inspect.</param>
        private void SetObjectToInspect(SceneObject so)
        {
            if (so == null)
            {
                return;
            }

            currentType = InspectorType.SceneObject;
            activeSO    = so;

            inspectorScrollArea = new GUIScrollArea();
            scrollAreaHighlight = new GUITexture(Builtin.WhiteTexture);
            scrollAreaHighlight.SetTint(HIGHLIGHT_COLOR);
            scrollAreaHighlight.Active = false;

            GUI.AddElement(inspectorScrollArea);
            GUIPanel inspectorPanel = inspectorScrollArea.Layout.AddPanel();

            inspectorLayout = inspectorPanel.AddLayoutY();
            highlightPanel  = inspectorPanel.AddPanel(-1);
            highlightPanel.AddElement(scrollAreaHighlight);

            // SceneObject fields
            CreateSceneObjectFields();
            RefreshSceneObjectFields(true);

            // Components
            Component[] allComponents = so.GetComponents();
            for (int i = 0; i < allComponents.Length; i++)
            {
                inspectorLayout.AddSpace(COMPONENT_SPACING);

                InspectorComponent data = new InspectorComponent();
                data.instanceId = allComponents[i].InstanceId;

                data.foldout = new GUIToggle(allComponents[i].GetType().Name, EditorStyles.Foldout);

                SpriteTexture xBtnIcon = EditorBuiltin.GetEditorIcon(EditorIcon.X);
                data.removeBtn = new GUIButton(new GUIContent(xBtnIcon), GUIOption.FixedWidth(30));

                data.title = inspectorLayout.AddLayoutX();
                data.title.AddElement(data.foldout);
                data.title.AddElement(data.removeBtn);
                data.panel = inspectorLayout.AddPanel();

                var persistentProperties = persistentData.GetProperties(allComponents[i].InstanceId);

                data.inspector = InspectorUtility.GetInspector(allComponents[i].GetType());
                data.inspector.Initialize(data.panel, allComponents[i], persistentProperties);

                bool isExpanded = data.inspector.Persistent.GetBool(data.instanceId + "_Expanded", true);
                data.foldout.Value = isExpanded;

                if (!isExpanded)
                {
                    data.inspector.SetVisible(false);
                }

                Type curComponentType = allComponents[i].GetType();
                data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded);
                data.removeBtn.OnClick += () => OnComponentRemoveClicked(curComponentType);

                inspectorComponents.Add(data);
            }

            inspectorLayout.AddFlexibleSpace();

            UpdateDropAreas();
        }
Example #34
0
File: Fade.cs Project: leedaju/COCO
 void Start()
 {
     Image = GetComponent <GUITexture> ();
     //Image = GetComponent<Texture>();
 }
Example #35
0
 // Use this for initialization
 void Start()
 {
     dragAndDropButton = GameObject.Find("DragButton").guiTexture;
     followNumbers     = GameObject.Find("FollowButton").guiTexture;
 }
Example #36
0
 void Awake()
 {
     guiTextureDude = gameObject.GetComponent <GUITexture> ();
     // Set the texture so that it is the the size of the screen and covers it.
     guiTextureDude.pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
 }
Example #37
0
 // Use this for initialization
 void Start()
 {
     textureIMG = this.GetComponent <GUITexture>() as GUITexture;
 }
    private PlayerControl playerCtrl;                   // Reference to the PlayerControl script.


    void Awake()
    {
        // Setting up the reference.
        bombHUD    = GameObject.Find("ui_bombHUD").GetComponent <GUITexture>();
        playerCtrl = GetComponent <PlayerControl> ();
    }
        override public float Run()
        {
            if (movieClipType == MovieClipType.VideoPlayer)
            {
                                #if ALLOW_VIDEO
                if (runtimeVideoPlayer != null)
                {
                    if (!isRunning)
                    {
                        isRunning = true;

                        if (movieMaterialMethod == MovieMaterialMethod.PlayMovie)
                        {
                                                        #if UNITY_WEBGL
                            if (!string.IsNullOrEmpty(movieURL))
                            {
                                runtimeVideoPlayer.url = movieURL;
                            }
                                                        #else
                            if (newClip != null)
                            {
                                runtimeVideoPlayer.clip = newClip;
                            }
                                                        #endif

                            if (prepareOnly)
                            {
                                runtimeVideoPlayer.Prepare();

                                if (willWait)
                                {
                                    return(defaultPauseTime);
                                }
                            }
                            else
                            {
                                KickStarter.playerInput.skipMovieKey = "";
                                runtimeVideoPlayer.Play();

                                if (runtimeVideoPlayer.isLooping)
                                {
                                    LogWarning("Cannot wait for " + runtimeVideoPlayer.name + " to finish because it is looping!");
                                    return(0f);
                                }

                                if (canSkip && skipKey != "")
                                {
                                    KickStarter.playerInput.skipMovieKey = skipKey;
                                }

                                if (willWait)
                                {
                                    return(defaultPauseTime);
                                }
                            }
                        }
                        else if (movieMaterialMethod == MovieMaterialMethod.PauseMovie)
                        {
                            runtimeVideoPlayer.Pause();
                        }
                        else if (movieMaterialMethod == MovieMaterialMethod.StopMovie)
                        {
                            runtimeVideoPlayer.Stop();
                        }

                        return(0f);
                    }
                    else
                    {
                        if (prepareOnly)
                        {
                            if (!runtimeVideoPlayer.isPrepared)
                            {
                                return(defaultPauseTime);
                            }
                        }
                        else
                        {
                            if (pauseWithGame)
                            {
                                if (KickStarter.stateHandler.gameState == GameState.Paused)
                                {
                                    if (runtimeVideoPlayer.isPlaying && !isPaused)
                                    {
                                        runtimeVideoPlayer.Pause();
                                        isPaused = true;
                                    }
                                    return(defaultPauseTime);
                                }
                                else
                                {
                                    if (!runtimeVideoPlayer.isPlaying && isPaused)
                                    {
                                        isPaused = false;
                                        runtimeVideoPlayer.Play();
                                    }
                                }
                            }

                            if (canSkip && skipKey != "" && KickStarter.playerInput.skipMovieKey == "")
                            {
                                runtimeVideoPlayer.Stop();
                                isRunning = false;
                                return(0f);
                            }

                            if (!runtimeVideoPlayer.isPrepared || runtimeVideoPlayer.isPlaying)
                            {
                                return(defaultPauseTime);
                            }
                        }

                        runtimeVideoPlayer.Stop();
                        isRunning = false;
                        return(0f);
                    }
                }
                else
                {
                    LogWarning("Cannot play video - no Video Player found!");
                }
                                #else
                LogWarning("Use of the VideoPlayer for movie playback is only available in Unity 5.6 or later.");
                                #endif
                return(0f);
            }

                        #if (UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_TVOS)
            if (!isRunning && filePath != "")
            {
                isRunning = true;

                if (canSkip)
                {
                    Handheld.PlayFullScreenMovie(filePath, Color.black, FullScreenMovieControlMode.CancelOnInput);
                }
                else
                {
                    Handheld.PlayFullScreenMovie(filePath, Color.black, FullScreenMovieControlMode.Hidden);
                }
                return(defaultPauseTime);
            }
            else
            {
                isRunning = false;
                return(0f);
            }
                        #elif UNITY_STANDALONE && (UNITY_5 || UNITY_2017_1_OR_NEWER || UNITY_PRO_LICENSE) && !UNITY_2017_2_OR_NEWER
            if (movieClip == null)
            {
                LogWarning("Cannot play movie - no movie clip set!");
                return(0f);
            }
            if (movieClipType == MovieClipType.OnMaterial && material == null)
            {
                LogWarning("Cannot play movie - no material has been assigned. A movie clip can only be played as a material's texture, so a material must be assigned.");
                return(0f);
            }
            if (includeAudio && sound == null)
            {
                LogWarning("Cannot play movie audio - no Sound object has been assigned.");
            }

            if (!isRunning)
            {
                isRunning  = true;
                guiTexture = null;

                KickStarter.playerInput.skipMovieKey = "";

                if (movieClipType == MovieClipType.FullScreen)
                {
                    CreateFullScreenMovie();
                }
                else if (movieClipType == MovieClipType.OnMaterial)
                {
                    if (movieMaterialMethod == MovieMaterialMethod.PlayMovie)
                    {
                        material.mainTexture = movieClip;
                    }
                    else if (movieMaterialMethod == MovieMaterialMethod.PauseMovie)
                    {
                        if (material.mainTexture == movieClip)
                        {
                            movieClip.Pause();
                            isRunning = false;
                            return(0f);
                        }
                    }
                    else if (movieMaterialMethod == MovieMaterialMethod.StopMovie)
                    {
                        if (material.mainTexture == movieClip)
                        {
                            movieClip.Stop();
                            isRunning = false;
                            return(0f);
                        }
                    }
                }

                movieClip.Play();

                if (includeAudio && sound != null)
                {
                    if (movieClipType == MovieClipType.OnMaterial && movieMaterialMethod != MovieMaterialMethod.PlayMovie)
                    {
                        if (movieMaterialMethod == MovieMaterialMethod.PauseMovie)
                        {
                            sound.GetComponent <AudioSource>().Pause();
                        }
                        else if (movieMaterialMethod == MovieMaterialMethod.StopMovie)
                        {
                            sound.Stop();
                        }
                    }
                    else
                    {
                        sound.GetComponent <AudioSource>().clip = movieClip.audioClip;
                        sound.Play(false);
                    }
                }

                if (movieClipType == MovieClipType.FullScreen || willWait)
                {
                    if (canSkip && skipKey != "")
                    {
                        KickStarter.playerInput.skipMovieKey = skipKey;
                    }
                    return(defaultPauseTime);
                }
                return(0f);
            }
            else
            {
                if (movieClip.isPlaying)
                {
                    if (!canSkip || KickStarter.playerInput.skipMovieKey != "")
                    {
                        return(defaultPauseTime);
                    }
                }

                OnComplete();
                isRunning = false;
                return(0f);
            }
                        #else
            LogWarning("On non-mobile platforms, this Action is only available in Unity 5 or Unity Pro.");
            return(0f);
                        #endif
        }
Example #40
0
 void Start()
 {
     red = GameObject.Find("RedScreen").GetComponent <GUITexture>();
     Update();         // to set texture alpha to 0 at beginning
 }
Example #41
0
 void Awake()
 {
     _display = gameObject.GetComponent <GUITexture>();
 }
Example #42
0
 protected override void Start()
 {
     base.Start();
     tex = GetComponent <GUITexture>();
 }
        private void OnInitialize()
        {
            guiOK     = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiOK.OnClick     += OnOK;
            guiCancel.OnClick += OnCancel;

            GUILayout mainVertLayout = GUI.AddLayoutY();

            mainVertLayout.AddSpace(10);

            GUILayout editorHorzLayout = mainVertLayout.AddLayoutX();

            editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);
            GUIPanel gradientEditorPanel = editorHorzLayout.AddPanel();

            editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);

            mainVertLayout.AddSpace(15);

            GUILayout buttonHorzLayout = mainVertLayout.AddLayoutX();

            buttonHorzLayout.AddFlexibleSpace();
            buttonHorzLayout.AddElement(guiOK);
            buttonHorzLayout.AddSpace(10);
            buttonHorzLayout.AddElement(guiCancel);
            buttonHorzLayout.AddFlexibleSpace();

            mainVertLayout.AddFlexibleSpace();

            editorPanel = gradientEditorPanel.AddPanel(0);
            GUIPanel editorOverlay = gradientEditorPanel.AddPanel(-1);

            overlayCanvas = new GUICanvas();
            editorOverlay.AddElement(overlayCanvas);

            GUILayout editorVertLayout = editorPanel.AddLayoutY();

            GUILayout guiGradientLayout = editorVertLayout.AddLayoutX();

            guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);

            texture       = Texture.Create2D(TEX_WIDTH, TEX_HEIGHT);
            spriteTexture = new SpriteTexture(texture);

            guiGradientTexture = new GUITexture(spriteTexture, GUITextureScaleMode.StretchToFit);
            guiGradientTexture.SetHeight(30);

            UpdateTexture();

            guiGradientLayout.AddElement(guiGradientTexture);
            guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);

            editorVertLayout.AddSpace(10);

            editor = new GradientKeyEditor(editorVertLayout, gradient.GetKeys(), Width - EDITOR_HORZ_PADDING * 2, 20);
            editor.OnGradientModified += colorGradient =>
            {
                gradient = colorGradient;

                UpdateTexture();
                UpdateKeyLines();
            };

            editorVertLayout.AddFlexibleSpace();

            GUITexture containerBg     = new GUITexture(null, EditorStylesInternal.ContainerBg);
            Rect2I     containerBounds = editor.GetBounds(GUI);

            containerBounds.x      -= 2;
            containerBounds.y      -= 2;
            containerBounds.width  += 4;
            containerBounds.height += 6;
            containerBg.Bounds      = containerBounds;

            GUIPanel editorUnderlay = GUI.AddPanel(1);

            editorUnderlay.AddElement(containerBg);

            UpdateKeyLines();

            EditorInput.OnPointerPressed     += OnPointerPressed;
            EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked;
            EditorInput.OnPointerMoved       += OnPointerMoved;
            EditorInput.OnPointerReleased    += OnPointerReleased;
            EditorInput.OnButtonUp           += OnButtonUp;
        }
Example #44
0
 // Use this for initialization
 void Start()
 {
     titlecard       = this.gameObject.GetComponent <GUITexture>();
     titlecard.color = new Color(0.5f, 0.5f, 0.5f, opacityFade);
 }
 void Awake()
 {
     thisTex = GetComponent <GUITexture>();
 }
Example #46
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch t = Input.GetTouch(0);

            /*
             * if (t.phase == TouchPhase.Began) {
             *      if (bt.HitTest (t.position, Camera.main)) {
             *
             *      }
             * }
             */
        }

        if (Input.GetMouseButtonDown(0))
        {
            //1st Column
            if (Love.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Love.GetComponent <GUITexture>();
                positionIndicator();
                audio.PlayOneShot(clip[2]);
            }

            if (Family.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Family.GetComponent <GUITexture>();
                positionIndicator();
                if (position != 0)
                {
                    family = true;
                    audio.PlayOneShot(clip[2]);
                }
            }

            if (Dreams.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Dreams.GetComponent <GUITexture>();
                positionIndicator();
                audio.PlayOneShot(clip[2]);
            }

            if (Philippines.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Philippines.GetComponent <GUITexture>();
                positionIndicator();
                if (position != 0)
                {
                    philippines = true;
                    audio.PlayOneShot(clip[2]);
                }
            }

            if (Sadness.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Sadness.GetComponent <GUITexture>();
                positionIndicator();
                audio.PlayOneShot(clip[2]);
            }

            //2nd Column
            if (Life.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Life.GetComponent <GUITexture>();
                positionIndicator();
                audio.PlayOneShot(clip[2]);
            }

            if (God.HitTest(Input.mousePosition, Camera.main))
            {
                Change = God.GetComponent <GUITexture>();
                positionIndicator();
                audio.PlayOneShot(clip[2]);
            }

            if (Farewell.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Farewell.GetComponent <GUITexture>();
                positionIndicator();
                if (position != 0)
                {
                    farewell = true;
                    audio.PlayOneShot(clip[2]);
                }
            }

            if (Patriot.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Patriot.GetComponent <GUITexture>();
                positionIndicator();
                if (position != 0)
                {
                    patriot = true;
                    audio.PlayOneShot(clip[2]);
                }
            }

            if (Hope.HitTest(Input.mousePosition, Camera.main))
            {
                Change = Hope.GetComponent <GUITexture>();
                positionIndicator();
                if (position != 0)
                {
                    hope = true;
                    audio.PlayOneShot(clip[2]);
                }
            }
            if (disableThis)
            {
                if (Reset.HitTest(Input.mousePosition, Camera.main))
                {
                    resetAll();
                    audio.PlayOneShot(clip[0]);
                }
            }

            if (disableThis)
            {
                if (OK.HitTest(Input.mousePosition, Camera.main))
                {
                    checkAnswers();
                    audio.PlayOneShot(clip[0]);
                }
            }

            if (disableFinish)
            {
                if (Finish.HitTest(Input.mousePosition, Camera.main))
                {
                    //Debug.Log("Change Scene");
                    storage.newer = 1;
                    Application.LoadLevel("New Act4 Part3 Scene1");
                    audio.PlayOneShot(clip[1]);
                }
            }
        }
    }
Example #47
0
    private GUITexture tex;                                           //外部添加的GUI组件

    void Start()                                                      //最先被调用的函数
    {
        tex            = this.GetComponent <GUITexture>();            //获取对象的GUITexture组件
        tex.pixelInset = new Rect(0, 0, Screen.width, Screen.height); //更改组件的位置信息,坐标为(0,0),大小为屏幕的宽高。
                                                                      //用于GUITexture的初始化
    }
Example #48
0
 void Start()
 {
     //获取组件GUITexture作为场景遮罩
     ChangeScreen       = GetComponent <GUITexture> ();
     ChangeScreen.color = new Color(0, 0, 0, 0);
 }
        /// <summary>
        /// Creates GUI elements required for displaying <see cref="SceneObject"/> fields like name, prefab data and
        /// transform (position, rotation, scale). Assumes that necessary inspector scroll area layout has already been
        /// created.
        /// </summary>
        private void CreateSceneObjectFields()
        {
            GUIPanel sceneObjectPanel = inspectorLayout.AddPanel();

            sceneObjectPanel.SetHeight(GetTitleBounds().height);

            GUILayoutY sceneObjectLayout = sceneObjectPanel.AddLayoutY();

            sceneObjectLayout.SetPosition(PADDING, PADDING);

            GUIPanel sceneObjectBgPanel = sceneObjectPanel.AddPanel(1);

            GUILayoutX nameLayout = sceneObjectLayout.AddLayoutX();

            soActiveToggle            = new GUIToggle("");
            soActiveToggle.OnToggled += OnSceneObjectActiveStateToggled;
            GUILabel nameLbl = new GUILabel(new LocEdString("Name"), GUIOption.FixedWidth(50));

            soNameInput              = new GUITextBox(false, GUIOption.FlexibleWidth(180));
            soNameInput.Text         = activeSO.Name;
            soNameInput.OnChanged   += OnSceneObjectRename;
            soNameInput.OnConfirmed += OnModifyConfirm;
            soNameInput.OnFocusLost += OnModifyConfirm;

            nameLayout.AddElement(soActiveToggle);
            nameLayout.AddSpace(3);
            nameLayout.AddElement(nameLbl);
            nameLayout.AddElement(soNameInput);
            nameLayout.AddFlexibleSpace();

            GUILayoutX mobilityLayout = sceneObjectLayout.AddLayoutX();
            GUILabel   mobilityLbl    = new GUILabel(new LocEdString("Mobility"), GUIOption.FixedWidth(50));

            soMobility       = new GUIEnumField(typeof(ObjectMobility), "", 0, GUIOption.FixedWidth(85));
            soMobility.Value = (ulong)activeSO.Mobility;
            soMobility.OnSelectionChanged += value => activeSO.Mobility = (ObjectMobility)value;
            mobilityLayout.AddElement(mobilityLbl);
            mobilityLayout.AddElement(soMobility);

            soPrefabLayout = sceneObjectLayout.AddLayoutX();

            GUILayoutX positionLayout = sceneObjectLayout.AddLayoutX();
            GUILabel   positionLbl    = new GUILabel(new LocEdString("Position"), GUIOption.FixedWidth(50));

            soPosX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60));
            soPosY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60));
            soPosZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60));

            soPosX.OnChanged += (x) => OnPositionChanged(0, x);
            soPosY.OnChanged += (y) => OnPositionChanged(1, y);
            soPosZ.OnChanged += (z) => OnPositionChanged(2, z);

            soPosX.OnConfirmed += OnModifyConfirm;
            soPosY.OnConfirmed += OnModifyConfirm;
            soPosZ.OnConfirmed += OnModifyConfirm;

            soPosX.OnFocusLost += OnModifyConfirm;
            soPosY.OnFocusLost += OnModifyConfirm;
            soPosZ.OnFocusLost += OnModifyConfirm;

            positionLayout.AddElement(positionLbl);
            positionLayout.AddElement(soPosX);
            positionLayout.AddSpace(10);
            positionLayout.AddFlexibleSpace();
            positionLayout.AddElement(soPosY);
            positionLayout.AddSpace(10);
            positionLayout.AddFlexibleSpace();
            positionLayout.AddElement(soPosZ);
            positionLayout.AddFlexibleSpace();

            GUILayoutX rotationLayout = sceneObjectLayout.AddLayoutX();
            GUILabel   rotationLbl    = new GUILabel(new LocEdString("Rotation"), GUIOption.FixedWidth(50));

            soRotX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60));
            soRotY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60));
            soRotZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60));

            soRotX.OnChanged += (x) => OnRotationChanged(0, x);
            soRotY.OnChanged += (y) => OnRotationChanged(1, y);
            soRotZ.OnChanged += (z) => OnRotationChanged(2, z);

            soRotX.OnConfirmed += OnModifyConfirm;
            soRotY.OnConfirmed += OnModifyConfirm;
            soRotZ.OnConfirmed += OnModifyConfirm;

            soRotX.OnFocusLost += OnModifyConfirm;
            soRotY.OnFocusLost += OnModifyConfirm;
            soRotZ.OnFocusLost += OnModifyConfirm;

            rotationLayout.AddElement(rotationLbl);
            rotationLayout.AddElement(soRotX);
            rotationLayout.AddSpace(10);
            rotationLayout.AddFlexibleSpace();
            rotationLayout.AddElement(soRotY);
            rotationLayout.AddSpace(10);
            rotationLayout.AddFlexibleSpace();
            rotationLayout.AddElement(soRotZ);
            rotationLayout.AddFlexibleSpace();

            GUILayoutX scaleLayout = sceneObjectLayout.AddLayoutX();
            GUILabel   scaleLbl    = new GUILabel(new LocEdString("Scale"), GUIOption.FixedWidth(50));

            soScaleX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60));
            soScaleY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60));
            soScaleZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60));

            soScaleX.OnChanged += (x) => OnScaleChanged(0, x);
            soScaleY.OnChanged += (y) => OnScaleChanged(1, y);
            soScaleZ.OnChanged += (z) => OnScaleChanged(2, z);

            soScaleX.OnConfirmed += OnModifyConfirm;
            soScaleY.OnConfirmed += OnModifyConfirm;
            soScaleZ.OnConfirmed += OnModifyConfirm;

            soScaleX.OnFocusLost += OnModifyConfirm;
            soScaleY.OnFocusLost += OnModifyConfirm;
            soScaleZ.OnFocusLost += OnModifyConfirm;

            scaleLayout.AddElement(scaleLbl);
            scaleLayout.AddElement(soScaleX);
            scaleLayout.AddSpace(10);
            scaleLayout.AddFlexibleSpace();
            scaleLayout.AddElement(soScaleY);
            scaleLayout.AddSpace(10);
            scaleLayout.AddFlexibleSpace();
            scaleLayout.AddElement(soScaleZ);
            scaleLayout.AddFlexibleSpace();

            sceneObjectLayout.AddFlexibleSpace();

            GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg);

            sceneObjectBgPanel.AddElement(titleBg);
        }
Example #50
0
    private void CreateMap()
    {
        OnlineMaps map = CreateMapGameObject();
        GameObject go  = map.gameObject;

        if (use3DControl == 0)
        {
            Texture2D texture = CreateTexture(map);

            if (mapControl2D == 0)
            {
                go.AddComponent <OnlineMapsGUITextureControl>();
                GUITexture guiTexture = go.GetComponent <GUITexture>();
                guiTexture.texture         = texture;
                go.transform.localPosition = new Vector3(0.5f, 0.5f);
                go.transform.localScale    = Vector3.zero;
                guiTexture.pixelInset      = new Rect(textureWidth / -2, textureHeight / -2, textureWidth, textureHeight);
            }
            else if (mapControl2D == 1)
            {
                go.AddComponent <OnlineMapsSpriteRendererControl>();
                SpriteRenderer spriteRenderer = go.GetComponent <SpriteRenderer>();
                spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, textureWidth, textureHeight), Vector2.zero);
                go.AddComponent <BoxCollider>();
            }
#if !UNITY_4_3 && !UNITY_4_5
            else if (mapControl2D == 2 || mapControl2D == 3)
            {
                RectTransform rectTransform = go.AddComponent <RectTransform>();
                rectTransform.SetParent(uGUIParent.transform as RectTransform);
                go.AddComponent <CanvasRenderer>();
                rectTransform.localPosition = Vector3.zero;
                rectTransform.anchorMax     = rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
                rectTransform.pivot         = new Vector2(0.5f, 0.5f);
                rectTransform.sizeDelta     = new Vector2(textureWidth, textureHeight);

                if (mapControl2D == 2)
                {
                    go.AddComponent <OnlineMapsUIImageControl>();
                    Image image = go.AddComponent <Image>();
                    image.sprite = Sprite.Create(texture, new Rect(0, 0, textureWidth, textureHeight), Vector2.zero);
                }
                else
                {
                    go.AddComponent <OnlineMapsUIRawImageControl>();
                    RawImage image = go.AddComponent <RawImage>();
                    image.texture = texture;
                }
            }
#endif
#if NGUI
            else if (mapControl2D == 4)
            {
                go.layer = NGUIParent.layer;
                UITexture uiTexture = go.AddComponent <UITexture>();
                uiTexture.mainTexture      = texture;
                uiTexture.width            = textureWidth;
                uiTexture.height           = textureHeight;
                go.transform.parent        = NGUIParent.transform;
                go.transform.localPosition = Vector3.zero;
                go.transform.localScale    = Vector3.one;
                go.transform.localRotation = Quaternion.Euler(Vector3.zero);
                BoxCollider boxCollider = go.AddComponent <BoxCollider>();
                boxCollider.size = new Vector3(textureWidth, textureHeight, 0);
                go.AddComponent <OnlineMapsNGUITextureControl>();
            }
#endif
#if DFGUI
            else if (mapControl2D == 5)
            {
                go.transform.parent = DFGUIParent.transform;

                dfTextureSprite textureSprite = go.AddComponent <dfTextureSprite>();
                textureSprite.Texture = texture;
                textureSprite.Width   = textureWidth;
                textureSprite.Height  = textureHeight;
                textureSprite.Pivot   = dfPivotPoint.MiddleCenter;
                textureSprite.transform.localPosition = Vector3.zero;

                go.AddComponent <OnlineMapsDFGUITextureControl>();
            }
#endif
#if IGUI
            else if (mapControl2D == 6)
            {
                go.transform.parent = IGUIParent.transform;

                iGUIImage image = go.AddComponent <iGUIImage>();
                image.image           = texture;
                image.positionAndSize = new Rect(0, 0, 1, 1);

                go.AddComponent <OnlineMapsIGUITextureControl>();
            }
#endif

            map.useSmartTexture = smartTexture;
            map.redrawOnPlay    = true;
        }
        else
        {
            OnlineMapsControlBase3D control3D = null;

            if (mapControl3D == 0)
            {
                map.target        = OnlineMapsTarget.tileset;
                map.tilesetWidth  = tilesetWidth;
                map.tilesetHeight = tilesetHeight;
                map.tilesetSize   = tilesetSize;

                OnlineMapsTileSetControl ts = go.AddComponent <OnlineMapsTileSetControl>();
                control3D         = ts;
                ts.useElevation   = useElevation;
                ts.bingAPI        = bingAPI;
                ts.smoothZoom     = smoothZoom;
                ts.tileMaterial   = tileMaterial;
                ts.markerMaterial = markerMaterial;
                ts.tilesetShader  = tilesetShader;
                ts.drawingShader  = drawingShader;
                ts.markerShader   = markerShader;

                if (moveCameraToTileset)
                {
                    GameObject cameraGO = activeCamera.gameObject;
                    float      minSide  = Mathf.Min(tilesetSize.x, tilesetSize.y);
                    Vector3    position = new Vector3(tilesetSize.x / -2, minSide, tilesetSize.y / 2);
                    cameraGO.transform.position = position;
                    cameraGO.transform.rotation = Quaternion.Euler(90, 180, 0);
                }

                if (useBuildings)
                {
                    go.AddComponent <OnlineMapsBuildings>();
                }
            }
            else if (mapControl3D == 1)
            {
                control3D           = go.AddComponent <OnlineMapsTextureControl>();
                map.useSmartTexture = smartTexture;
                map.redrawOnPlay    = true;
            }

            if (control3D != null)
            {
                control3D.activeCamera       = activeCamera;
                control3D.allowCameraControl = allowCameraControl;
            }
        }

        if (useLocationService)
        {
            go.AddComponent <OnlineMapsLocationService>();
        }
        if (useRWT)
        {
            go.AddComponent <OnlineMapsRWTConnector>();
        }

        EditorGUIUtility.PingObject(go);
        Selection.activeGameObject = go;
    }
 void Start()
 {
     myGUITexture   = GetComponent <GUITexture>();
     defaultTexture = (Texture2D)myGUITexture.texture;
 }
Example #52
0
 void Start()
 {
     guiTex = GetComponent <GUITexture>();
 }
Example #53
0
        private void OnInitialize()
        {
            GUILayoutY layout      = GUI.AddLayoutY();
            GUILayoutX titleLayout = layout.AddLayoutX();

            GUIContentImages infoImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 16, true));

            GUIContentImages warningImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 16, true));

            GUIContentImages errorImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 16, true));

            GUIToggle infoBtn    = new GUIToggle(new GUIContent(infoImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle warningBtn = new GUIToggle(new GUIContent(warningImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle errorBtn   = new GUIToggle(new GUIContent(errorImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));

            GUIToggle detailsBtn     = new GUIToggle(new LocEdString("Show details"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIButton clearBtn       = new GUIButton(new LocEdString("Clear"), GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle clearOnPlayBtn = new GUIToggle(new LocEdString("Clear on play"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));

            titleLayout.AddElement(infoBtn);
            titleLayout.AddElement(warningBtn);
            titleLayout.AddElement(errorBtn);
            titleLayout.AddFlexibleSpace();
            titleLayout.AddElement(detailsBtn);
            titleLayout.AddElement(clearBtn);
            titleLayout.AddElement(clearOnPlayBtn);

            infoBtn.Value    = filter.HasFlag(EntryFilter.Info);
            warningBtn.Value = filter.HasFlag(EntryFilter.Warning);
            errorBtn.Value   = filter.HasFlag(EntryFilter.Error);

            clearOnPlayBtn.Value = EditorSettings.GetBool(CLEAR_ON_PLAY_KEY, true);

            infoBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Info);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Info);
                }
            };

            warningBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Warning);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Warning);
                }
            };

            errorBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Error);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Error);
                }
            };

            detailsBtn.OnToggled     += ToggleDetailsPanel;
            clearBtn.OnClick         += ClearLog;
            clearOnPlayBtn.OnToggled += ToggleClearOnPlay;

            GUILayoutX mainLayout = layout.AddLayoutX();

            listView = new GUIListView <ConsoleGUIEntry, ConsoleEntryData>(Width, ListHeight, ENTRY_HEIGHT, mainLayout);

            detailsSeparator = new GUITexture(Builtin.WhiteTexture, GUIOption.FixedWidth(SEPARATOR_WIDTH));
            detailsArea      = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);
            mainLayout.AddElement(detailsSeparator);
            mainLayout.AddElement(detailsArea);
            detailsSeparator.Active = false;
            detailsArea.Active      = false;

            detailsSeparator.SetTint(SEPARATOR_COLOR);

            Refresh();
            Debug.OnAdded += OnEntryAdded;
        }
        /// <summary>
        /// Rebuilds the GUI dictionary header if needed.
        /// </summary>
        protected void UpdateHeaderGUI()
        {
            Action BuildEmptyGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                guiInternalTitleLayout.AddElement(new GUILabel(title));
                guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100)));

                GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create),
                                                       new LocEdString("Create"));
                GUIButton createBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30));
                createBtn.OnClick += OnCreateButtonClicked;
                guiInternalTitleLayout.AddElement(createBtn);
            };

            Action BuildFilledGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);
                guiFoldout.Value      = isExpanded;
                guiFoldout.OnToggled += ToggleFoldout;

                GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear),
                                                      new LocEdString("Clear"));
                GUIButton guiClearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(30));
                guiClearBtn.OnClick += OnClearButtonClicked;

                GUIContent addIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Add),
                                                    new LocEdString("Add"));
                GUIButton guiAddBtn = new GUIButton(addIcon, GUIOption.FixedWidth(30));
                guiAddBtn.OnClick += OnAddButtonClicked;

                guiInternalTitleLayout.AddElement(guiFoldout);
                guiInternalTitleLayout.AddElement(guiAddBtn);
                guiInternalTitleLayout.AddElement(guiClearBtn);

                guiChildLayout = guiLayout.AddLayoutX();
                guiChildLayout.AddSpace(IndentAmount);

                GUIPanel   guiContentPanel  = guiChildLayout.AddPanel();
                GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();
                guiIndentLayoutX.AddSpace(IndentAmount);
                GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
                guiIndentLayoutY.AddSpace(IndentAmount);
                guiContentLayout = guiIndentLayoutY.AddLayoutY();
                guiIndentLayoutY.AddSpace(IndentAmount);
                guiIndentLayoutX.AddSpace(IndentAmount);
                guiChildLayout.AddSpace(IndentAmount);

                short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
                string bgPanelStyle    = depth % 2 == 0
                    ? EditorStyles.InspectorContentBgAlternate
                    : EditorStyles.InspectorContentBg;

                GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
                GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                backgroundPanel.AddElement(inspectorContentBg);

                ToggleFoldout(isExpanded);
            };

            if (state == State.None)
            {
                if (!IsNull())
                {
                    BuildFilledGUI();
                    state = State.Filled;
                }
                else
                {
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
            else if (state == State.Empty)
            {
                if (!IsNull())
                {
                    guiInternalTitleLayout.Destroy();
                    BuildFilledGUI();
                    state = State.Filled;
                }
            }
            else if (state == State.Filled)
            {
                if (IsNull())
                {
                    guiInternalTitleLayout.Destroy();
                    guiChildLayout.Destroy();
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
        }
Example #55
0
 void Start()
 {
     texture = GetComponent <GUITexture>();
 }
Example #56
0
 public void Start()
 {
     tweenScale = GetComponent <TweenScale>();
     guiTexture = GetComponent <GUITexture>();
     DontDestroyOnLoad(this.gameObject);
 }
Example #57
0
            /// <summary>
            /// Builds GUI for the specified GUI element style.
            /// </summary>
            /// <param name="layout">Layout to append the GUI elements to.</param>
            /// <param name="depth">Determines the depth at which the element is rendered.</param>
            public void BuildGUI(GUILayout layout, int depth)
            {
                short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
                string bgPanelStyle    = depth % 2 == 0
                    ? EditorStylesInternal.InspectorContentBgAlternate
                    : EditorStylesInternal.InspectorContentBg;

                GUIToggle foldout = new GUIToggle(new LocEdString("Style"), EditorStyles.Foldout);

                foldout.AcceptsKeyFocus = false;

                GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);

                layout.AddElement(foldout);
                GUIPanel panel           = layout.AddPanel();
                GUIPanel backgroundPanel = panel.AddPanel(backgroundDepth);

                backgroundPanel.AddElement(inspectorContentBg);

                GUILayoutX guiIndentLayoutX = panel.AddLayoutX();

                guiIndentLayoutX.AddSpace(IndentAmount);
                GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();

                guiIndentLayoutY.AddSpace(IndentAmount);
                GUILayoutY contentLayout = guiIndentLayoutY.AddLayoutY();

                guiIndentLayoutY.AddSpace(IndentAmount);
                guiIndentLayoutX.AddSpace(IndentAmount);

                fontField          = new GUIResourceField(typeof(Font), new LocEdString("Font"));
                fontSizeField      = new GUIIntField(new LocEdString("Font size"));
                horzAlignField     = new GUIEnumField(typeof(TextHorzAlign), new LocEdString("Horizontal alignment"));
                vertAlignField     = new GUIEnumField(typeof(TextVertAlign), new LocEdString("Vertical alignment"));
                imagePositionField = new GUIEnumField(typeof(GUIImagePosition), new LocEdString("Image position"));
                wordWrapField      = new GUIToggleField(new LocEdString("Word wrap"));

                contentLayout.AddElement(fontField);
                contentLayout.AddElement(fontSizeField);
                contentLayout.AddElement(horzAlignField);
                contentLayout.AddElement(vertAlignField);
                contentLayout.AddElement(imagePositionField);
                contentLayout.AddElement(wordWrapField);

                normalGUI.BuildGUI(new LocEdString("Normal"), contentLayout);
                hoverGUI.BuildGUI(new LocEdString("Hover"), contentLayout);
                activeGUI.BuildGUI(new LocEdString("Active"), contentLayout);
                focusedGUI.BuildGUI(new LocEdString("Focused"), contentLayout);
                normalOnGUI.BuildGUI(new LocEdString("NormalOn"), contentLayout);
                hoverOnGUI.BuildGUI(new LocEdString("HoverOn"), contentLayout);
                activeOnGUI.BuildGUI(new LocEdString("ActiveOn"), contentLayout);
                focusedOnGUI.BuildGUI(new LocEdString("FocusedOn"), contentLayout);

                borderGUI        = new RectOffsetGUI(new LocEdString("Border"), contentLayout);
                marginsGUI       = new RectOffsetGUI(new LocEdString("Margins"), contentLayout);
                contentOffsetGUI = new RectOffsetGUI(new LocEdString("Content offset"), contentLayout);

                fixedWidthField = new GUIToggleField(new LocEdString("Fixed width"));
                widthField      = new GUIIntField(new LocEdString("Width"));
                minWidthField   = new GUIIntField(new LocEdString("Min. width"));
                maxWidthField   = new GUIIntField(new LocEdString("Max. width"));

                fixedHeightField = new GUIToggleField(new LocEdString("Fixed height"));
                heightField      = new GUIIntField(new LocEdString("Height"));
                minHeightField   = new GUIIntField(new LocEdString("Min. height"));
                maxHeightField   = new GUIIntField(new LocEdString("Max. height"));

                contentLayout.AddElement(fixedWidthField);
                contentLayout.AddElement(widthField);
                contentLayout.AddElement(minWidthField);
                contentLayout.AddElement(maxWidthField);

                contentLayout.AddElement(fixedHeightField);
                contentLayout.AddElement(heightField);
                contentLayout.AddElement(minHeightField);
                contentLayout.AddElement(maxHeightField);

                foldout.OnToggled += x =>
                {
                    panel.Active = x;
                    isExpanded   = x;
                };

                fontField.OnChanged += x =>
                {
                    Font font = Resources.Load <Font>(x.UUID);

                    GetStyle().Font = font;
                    MarkAsModified();
                    ConfirmModify();
                };
                fontSizeField.OnChanged           += x => { GetStyle().FontSize = x; MarkAsModified(); };
                fontSizeField.OnFocusLost         += ConfirmModify;
                fontSizeField.OnConfirmed         += ConfirmModify;
                horzAlignField.OnSelectionChanged += x =>
                {
                    GetStyle().TextHorzAlign = (TextHorzAlign)x;
                    MarkAsModified();
                    ConfirmModify();
                };
                vertAlignField.OnSelectionChanged += x =>
                {
                    GetStyle().TextVertAlign = (TextVertAlign)x;
                    MarkAsModified();
                    ConfirmModify();
                };
                imagePositionField.OnSelectionChanged += x =>
                {
                    GetStyle().ImagePosition = (GUIImagePosition)x;
                    MarkAsModified();
                    ConfirmModify();
                };
                wordWrapField.OnChanged += x => { GetStyle().WordWrap = x; MarkAsModified(); ConfirmModify(); };

                normalGUI.OnChanged    += x => { GetStyle().Normal = x; MarkAsModified(); ConfirmModify(); };
                hoverGUI.OnChanged     += x => { GetStyle().Hover = x; MarkAsModified(); ConfirmModify(); };
                activeGUI.OnChanged    += x => { GetStyle().Active = x; MarkAsModified(); ConfirmModify(); };
                focusedGUI.OnChanged   += x => { GetStyle().Focused = x; MarkAsModified(); ConfirmModify(); };
                normalOnGUI.OnChanged  += x => { GetStyle().NormalOn = x; MarkAsModified(); ConfirmModify(); };
                hoverOnGUI.OnChanged   += x => { GetStyle().HoverOn = x; MarkAsModified(); ConfirmModify(); };
                activeOnGUI.OnChanged  += x => { GetStyle().ActiveOn = x; MarkAsModified(); ConfirmModify(); };
                focusedOnGUI.OnChanged += x => { GetStyle().FocusedOn = x; MarkAsModified(); ConfirmModify(); };

                borderGUI.OnChanged        += x => { GetStyle().Border = x; MarkAsModified(); };
                marginsGUI.OnChanged       += x => { GetStyle().Margins = x; MarkAsModified(); };
                contentOffsetGUI.OnChanged += x => { GetStyle().ContentOffset = x; MarkAsModified(); };

                borderGUI.OnConfirmed        += ConfirmModify;
                marginsGUI.OnConfirmed       += ConfirmModify;
                contentOffsetGUI.OnConfirmed += ConfirmModify;

                fixedWidthField.OnChanged += x => { GetStyle().FixedWidth = x; MarkAsModified(); ConfirmModify(); };
                widthField.OnChanged      += x => GetStyle().Width = x;
                widthField.OnFocusLost    += ConfirmModify;
                widthField.OnConfirmed    += ConfirmModify;
                minWidthField.OnChanged   += x => GetStyle().MinWidth = x;
                minWidthField.OnFocusLost += ConfirmModify;
                minWidthField.OnConfirmed += ConfirmModify;
                maxWidthField.OnChanged   += x => GetStyle().MaxWidth = x;
                maxWidthField.OnFocusLost += ConfirmModify;
                maxWidthField.OnConfirmed += ConfirmModify;

                fixedHeightField.OnChanged += x => { GetStyle().FixedHeight = x; MarkAsModified(); ConfirmModify(); };
                heightField.OnChanged      += x => GetStyle().Height = x;
                heightField.OnFocusLost    += ConfirmModify;
                heightField.OnConfirmed    += ConfirmModify;
                minHeightField.OnChanged   += x => GetStyle().MinHeight = x;
                minHeightField.OnFocusLost += ConfirmModify;
                minHeightField.OnConfirmed += ConfirmModify;
                maxHeightField.OnChanged   += x => GetStyle().MaxHeight = x;
                maxHeightField.OnFocusLost += ConfirmModify;
                maxHeightField.OnConfirmed += ConfirmModify;

                foldout.Value = isExpanded;
                panel.Active  = isExpanded;
            }
Example #58
0
    private void Awake()
    {
        gui = GetComponent <GUITexture>();
        if (gui.texture == null)
        {
            Debug.LogError("Joystick object requires a valid texture!");
            gameObject.active = false;
            return;
        }

        if (!enumeratedJoysticks)
        {
            try
            {
                /* Collect all joysticks in the game, so we can relay finger latching messages */
                GameObject[] objs = GameObject.FindGameObjectsWithTag(joysticksTag);
                joysticks = new List <Joystick>(objs.Length);
                foreach (GameObject obj in objs)
                {
                    Joystick newJoystick = obj.GetComponent <Joystick>();
                    if (newJoystick == null)
                    {
                        throw new NullReferenceException("Joystick gameObject found without a suitable Joystick component.");
                    }
                    joysticks.Add(newJoystick);
                }
                enumeratedJoysticks = true;
            }
            catch (Exception exp)
            {
                Debug.LogError("Error collecting Joystick objects: " + exp.Message);
                throw;
            }
        }

        /* Store the default rect for the gui, so we can snap back to it */
        defaultRect = gui.pixelInset;

        defaultRect.x += transform.position.x * Screen.width;  // + gui.pixelInset.x; // -  Screen.width * 0.5f;
        defaultRect.y += transform.position.y * Screen.height; // - Screen.height * 0.5f;

        transform.position = new Vector3(0, 0, transform.position.z);

        if (touchPad)
        {
            /* Use the rect from the gui as our touchZone */
            touchZone = defaultRect;
        }
        else
        {
            /* This is an offset for touch input to match with the top left corner of the GUI */
            guiTouchOffset.x = defaultRect.width * 0.5f;
            guiTouchOffset.y = defaultRect.height * 0.5f;

            /* Cache the center of the GUI, since it doesn't change */
            guiCenter.x = defaultRect.x + guiTouchOffset.x;
            guiCenter.y = defaultRect.y + guiTouchOffset.y;

            /* Let's build the GUI boundary, so we can clamp joystick movement */
            guiBoundary.min.x = defaultRect.x - guiTouchOffset.x;
            guiBoundary.max.x = defaultRect.x + guiTouchOffset.x;
            guiBoundary.min.y = defaultRect.y - guiTouchOffset.y;
            guiBoundary.max.y = defaultRect.y + guiTouchOffset.y;
        }
    }
Example #59
0
    public void Position_Minimap_Markers_XZ(Location thisLocation, GUITexture thisMiniMapMarker)
    {
        // calculate the distance from this location to the camera.
        float Distance2D = Mathf.Abs(Vector2.Distance(new Vector2(Tracking_Camera.transform.position.x, Tracking_Camera.transform.position.z),
                                                      new Vector2(thisLocation.transform.position.x, thisLocation.transform.position.z)));

        // if distance is zero we are directly ontop of the location.
        // calculate the direction between the camera and the location, normalised it.
        Vector3 Direction3D = Tracking_Camera.transform.position - thisLocation.transform.position;

        // the vector perpendicular to referenceForward, 90 degrees clockwise, is used to determine if angle is positive or negative.
        Vector3 Right3D = Vector3.Cross(Vector3.up, Tracking_Camera.transform.forward);

        // get the angle in degrees between 0 and 180
        float Angle = Vector2.Angle(new Vector2(Direction3D.x, Direction3D.z), new Vector2(-Tracking_Camera.transform.forward.x, -Tracking_Camera.transform.forward.z));

        // determine if the degree value should be negative.
        // a positive value from the dot product means that our vector is on the right of the reference vector.
        float Sign_Value = Mathf.Sign(Vector3.Dot(Direction3D, Right3D));

        // use the sign to get the final angle value.
        float Final_Angle = Sign_Value * Angle;

        // calculate the 2D map center position using the bottom left and taking away the width of the marker (10.0f / 2.0f = 5.0f).
        Vector2 Center2D = new Vector2(Minimap_Position.x, ScaledYPosition) + new Vector2((Minimap_Scale / 2.0f) - 5.0f, (Minimap_Scale / 2.0f) - 5.0f);

        // calculate the new 2D position using the center, 3D direction and 3D distance.
        Vector2 Position2D = Center2D + new Vector2(Direction3D.normalized.x * Distance2D * Distance_Scale, Direction3D.normalized.z * Distance2D * Distance_Scale);

        // calculate the total distance using the distance scale variable.
        float Final_Distance = Distance2D * Distance_Scale;

        if (Show_OffScreen_On_Edge)
        {
            // limit the distance if required to show just off screen markers.
            if ((Distance2D * Distance_Scale) > Minimap_Scale * 0.425f)
            {
                // limit the scale.
                Final_Distance = Minimap_Scale * 0.45f;
            }
        }

        // calculate the new direction using the 2D Angle.
        Vector3 RotatedPosition = new Vector2(Position2D.x = Center2D.x + Final_Distance * Mathf.Cos(Mathf.Deg2Rad * (Final_Angle + 90.0f)),
                                              Position2D.y = Center2D.y + Final_Distance * Mathf.Sin(Mathf.Deg2Rad * (Final_Angle + 90.0f)));

        // slightly scale the icons based on their distance for a nice fade out to the edge.
        float Final_Scale = 10.0f * Mathf.Clamp((1.5f - (Final_Distance / (Minimap_Scale * 0.5f))), 0.25f, 1.0f);

        // display the markers differently depending on the options we select.
        if (Show_OffScreen_On_Edge)
        {
            // position this minimap marker using the locations specification.
            thisMiniMapMarker.pixelInset = new Rect(Position2D.x, Position2D.y, Final_Scale, Final_Scale);
        }
        else
        {
            // check that the position is actually still on the display (if not then do not show it).
            if ((Distance2D * Distance_Scale) < Minimap_Scale * 0.475f)
            {
                // position this minimap marker using the locations specification.
                thisMiniMapMarker.pixelInset = new Rect(Position2D.x, Position2D.y, Final_Scale, Final_Scale);
            }
            else
            {
                thisMiniMapMarker.pixelInset = new Rect(Position2D.x, Position2D.y, 0.0f, 0.0f);
            }
        }
    }
Example #60
0
 void Start()
 {
     mapGuiTexture = this.GetComponent <GUITexture> ();
     GetPos();
     GetMap();
 }