Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 protected virtual void Awake()
 {
     if (m_Instance == null)
     {
         m_Instance = Instance;
     }
 }
Esempio n. 2
0
    /// <summary>
    ///
    /// </summary>
    void OnFocus()
    {
        // if application is not playing, find a vp_Input instance in resources
        GameObject go = Resources.Load("Input/vp_Input") as GameObject;

        // if not found create it
        if (go == null)
        {
#if UNITY_EDITOR
            vp_Input.CreateMissingInputPrefab(vp_Input.PrefabPath, vp_Input.FolderPath);
            go = Resources.Load("Input/vp_Input") as GameObject;
#endif
            if (go == null)
            {
                Debug.LogError("Error (" + this + ") Failed to create input manager.");
                return;
            }
        }

        m_Component = go.GetComponent <vp_Input>();
        if (m_Component == null)
        {
            m_Component = go.AddComponent <vp_Input>();
        }

        m_Component.SetupDefaults();

        m_Component.SetDirty(true);
    }
    void OnFocus()
    {
        // if application is not playing, find a vp_Input instance in resources
        GameObject go = Resources.Load("Input/vp_Input") as GameObject;

        // if not found create it
        if (go == null)
        {
            vp_Input.CreateIfNoExist();
            go = Resources.Load("Input/vp_Input") as GameObject;
        }

        m_Component = go.GetComponent <vp_Input>();
        if (m_Component == null)
        {
            m_Component = go.AddComponent <vp_Input>();
        }

        m_Component.SetupDefaults();

        m_Component.SetDirty(true);
    }
Esempio n. 4
0
    /// <summary>
    /// In this method, vp_Input is loaded from resources
    /// and all its properties are copied here
    /// </summary>
    protected override void Awake()
    {
        GameObject go    = Resources.Load("Input/vp_Input") as GameObject;
        vp_Input   input = go != null?go.GetComponent <vp_Input>() : new GameObject("vp_Input").AddComponent <vp_Input>();

        ControlType  = input.ControlType;
        Buttons      = input.Buttons;
        Axis         = input.Axis;
        UnityAxis    = input.UnityAxis;
        ButtonKeys   = input.ButtonKeys;
        ButtonValues = input.ButtonValues;
        AxisKeys     = input.AxisKeys;
        AxisValues   = input.AxisValues;

        // set the vp_Input instance to this class to allow touch input
        m_Instance = this;

        SetupDefaults();

        // sets the target frame rate higher for mobile
        Application.targetFrameRate = 60;
    }
Esempio n. 5
0
 /// <summary>
 /// 
 /// </summary>
 protected virtual void Awake()
 {
     if(m_Instance == null)
         m_Instance = Instance;
 }
Esempio n. 6
0
    void OnFocus()
    {
    
    	// if application is not playing, find a vp_Input instance in resources
		GameObject go = Resources.Load("Input/vp_Input") as GameObject;
		
		// if not found create it
		if(go == null)
		{
			vp_Input.CreateIfNoExist();
			go = Resources.Load("Input/vp_Input") as GameObject;
		}
		
		m_Component = go.GetComponent<vp_Input>();
		if(m_Component == null)
			m_Component = go.AddComponent<vp_Input>();
			
		m_Component.SetupDefaults();
    		
		m_Component.SetDirty(true);
    
    }
Esempio n. 7
0
    /// <summary>
    ///
    /// </summary>
    protected override void DoInspector()
    {
        base.DoInspector();

        vp_Input inputManager = null;

        vp_Input[] inputs = Resources.FindObjectsOfTypeAll(typeof(vp_Input)) as vp_Input[];
        if (inputs.Length > 0)
        {
            inputManager = inputs[0];
        }

        // if no instance was found, try and load it from resources
        if (inputManager == null)
        {
            GameObject go = Resources.Load("Input/vp_Input") as GameObject;
            if (go != null)
            {
                inputManager = go.GetComponent <vp_Input>();
            }
        }

        if (inputManager == null)
        {
            EditorGUILayout.HelpBox("Could not find a vp_InputManager component in the hierarchy.", MessageType.Info);
            return;
        }

        List <string> buttons = inputManager.ButtonKeys;

        if (buttons == null)
        {
            EditorGUILayout.HelpBox("No Buttons have been added to the Input Manager.", MessageType.Info);
            return;
        }

        GUILayout.Space(10);

        m_Target.OverrideTouches = m_Target.Manager != null?EditorGUILayout.Toggle("Override Touches", m_Target.OverrideTouches) : false;

        string[] buttonStrings = new string[buttons.Count + 2];
        buttonStrings[0] = "Event Binding \u21C6";
        buttonStrings[1] = "";
        int id = 0;

        for (int i = 0; i < buttons.Count; ++i)
        {
            if (buttons[i] == m_Target.Action)
            {
                id = i + 2;
            }

            buttonStrings[i + 2] = buttons[i];
        }

        m_Target.Event = (vp_UITouchButton.vp_UIButtonState)EditorGUILayout.EnumPopup("Event", m_Target.Event);
        if (m_Target.Event == vp_UITouchButton.vp_UIButtonState.OnDoubleRelease || m_Target.Event == vp_UITouchButton.vp_UIButtonState.OnRelease)
        {
            m_Target.RequireStayInBounds = EditorGUILayout.Toggle(new GUIContent("Require Stay in Bounds", "When this is on, the event will only trigger if the touch stays within the button's bounds from the time the touch begins to when it ends."), m_Target.RequireStayInBounds);
        }

        int newId = EditorGUILayout.Popup("Perform Action", id, buttonStrings);

        m_Target.Action = buttonStrings[newId];

        if (m_Target.Action != "Event Binding \u21C6")
        {
            return;
        }

        GUILayout.Space(10);

        ShowEventBindingInspector(m_Target);
    }