Example #1
0
    protected vp_UIManager m_Manager           = null;                          // cached uimanager


    /// <summary>
    ///
    /// </summary>
    protected virtual void Awake()
    {
        m_Manager = transform.root.GetComponentInChildren <vp_UIManager>();
        m_Camera  = m_Manager.Player.GetComponentInChildren <vp_FPCamera>();

        SetObjectPositions();
    }
Example #2
0
    static void CreateUIRoot()
    {
        Undo.RegisterSceneUndo("Create UI Root");

        GameObject   rootGO  = new GameObject("UIRoot");
        vp_UIManager manager = rootGO.AddComponent <vp_UIManager>();

        rootGO.layer = manager.UILayer;

        GameObject cameraGO = new GameObject("UICamera");

        cameraGO.transform.parent = rootGO.transform;
        cameraGO.layer            = rootGO.layer;
        Camera camera = cameraGO.AddComponent <Camera>();

        camera.cullingMask      = 1 << manager.UILayer;
        camera.orthographic     = true;
        camera.orthographicSize = 1;
        camera.nearClipPlane    = -10;
        camera.farClipPlane     = 10;

        cameraGO.AddComponent <vp_UICamera>();

        Selection.activeGameObject = rootGO;
    }
Example #3
0
    protected List<Vector3> m_ObjectScales = new List<Vector3>(); // cached list of swayable objects position's

    #endregion Fields

    #region Methods

    /// <summary>
    /// 
    /// </summary>
    protected virtual void Awake()
    {
        m_Manager = transform.root.GetComponentInChildren<vp_UIManager>();
        m_Camera = m_Manager.Player.GetComponentInChildren<vp_FPCamera>();

        SetObjectPositions();
    }
Example #4
0
    /// <summary>
    /// hooks up the component object as the inspector target
    /// </summary>
    public virtual void OnEnable()
    {
        m_Component = (vp_UIManager)target;

        if(m_Component.UICamera == null)
            m_Component.UICamera = vp_UIManager.GetUICamera(m_Component.transform);

        if(!Application.isPlaying)
            m_Component.ForceUIRefresh();
    }
Example #5
0
    /// <summary>
    /// hooks up the component object as the inspector target
    /// </summary>
    public virtual void OnEnable()
    {
        m_Component = (vp_UIManager)target;

        if (m_Component.UICamera == null)
        {
            m_Component.UICamera = vp_UIManager.GetUICamera(m_Component.transform);
        }

        if (!Application.isPlaying)
        {
            m_Component.ForceUIRefresh();
        }
    }
Example #6
0
    /// <summary>
    /// Makes sure all the necessary properties are set
    /// </summary>
    protected virtual void Init()
    {
        m_Transform = transform;

        if (Manager == null)
        {
            Manager = m_Transform.root.GetComponent <vp_UIManager>();
        }

        if (Controls == null || Controls.Count == 0 || Application.isPlaying)
        {
            Controls = m_Transform.ChildComponentsToList <vp_UIControl>();
        }
    }
Example #7
0
 /// <summary>
 /// 
 /// </summary>
 protected virtual void Awake()
 {
     m_Manager = transform.root.GetComponent<vp_UIManager>();
 }
Example #8
0
    /// <summary>
    /// Makes sure all the necessary properties are set
    /// </summary>
    protected virtual void Init()
    {
        m_Transform = transform;

        if(Manager == null)
            Manager = m_Transform.root.GetComponent<vp_UIManager>();

        if(Controls == null || Controls.Count == 0 || Application.isPlaying)
            Controls = m_Transform.ChildComponentsToList<vp_UIControl>();
    }
Example #9
0
    /// <summary>
    ///
    /// </summary>
    protected virtual void Awake()
    {
        m_Transform = transform;
        m_Camera    = vp_UIManager.GetUICamera(m_Transform) == null?m_Transform.root.GetComponentInChildren <Camera>() : vp_UIManager.GetUICamera(m_Transform);

        m_Parent       = m_Transform.parent;
        Manager        = m_Transform.root.GetComponentInChildren <vp_UIManager>();
        m_LastFingerID = -1;
        if (GetComponent <Collider>() != null)
        {
            m_Collider = GetComponents <BoxCollider>().FirstOrDefault();
        }

        // Auto register events
        List <string> supportedButtonMethods = new List <string>()
        {
            "OnPressControl", "OnHoldControl", "OnReleaseControl", "OnDoublePressControl", "OnDoubleReleaseControl"
        };
        List <string> supportedToggleMethods = new List <string>()
        {
            "OnChangeControl"
        };

        List <MonoBehaviour> components = GetComponents <MonoBehaviour>().ToList();

        for (int i = 0; i < components.Count; i++)
        {
            MonoBehaviour component   = components[i];
            MethodInfo[]  methodInfos = component.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            foreach (MethodInfo methodInfo in methodInfos)
            {
                if (methodInfo.GetParameters().Length == 0 && methodInfo.ReturnType == typeof(void))
                {
                    foreach (string methodName in supportedButtonMethods)
                    {
                        if (methodInfo.Name == methodName)
                        {
                            m_ButtonEvents.Add((vp_TouchButtonEventBinding)Delegate.CreateDelegate(typeof(vp_TouchButtonEventBinding), component, methodName));
                        }
                    }
                }
                else if (methodInfo.GetParameters().Length == 1 && methodInfo.GetParameters()[0].ParameterType == typeof(vp_UIControl) && methodInfo.ReturnType == typeof(void))
                {
                    foreach (string methodName in supportedToggleMethods)
                    {
                        if (methodInfo.Name == methodName)
                        {
                            m_ChangedEvents.Add((vp_TouchChangedEventBinding)Delegate.CreateDelegate(typeof(vp_TouchChangedEventBinding), component, methodName));
                        }
                    }
                }
            }
        }


        // setup changed events
        for (int i = 0; i < Objects.Count; i++)
        {
            if (Objects[i] == null || Methods[i] == "")
            {
                continue;
            }

            string[] info = Methods[i].Split(new string[1] {
                "."
            }, System.StringSplitOptions.None);
            Component component = (Component)Objects[i].GetComponent(info[0]);
            if (component.GetType().GetMethod(info[1]).GetParameters().Length > 0)
            {
                m_ChangedEvents.Add((vp_TouchChangedEventBinding)Delegate.CreateDelegate(typeof(vp_TouchChangedEventBinding), component, info[1]));
            }
            else if (component.GetType().GetMethod(info[1]).GetParameters().Length == 0)
            {
                m_ButtonEvents.Add((vp_TouchButtonEventBinding)Delegate.CreateDelegate(typeof(vp_TouchButtonEventBinding), component, info[1]));
            }
        }
    }
Example #10
0
    /// <summary>
    /// 
    /// </summary>
    protected virtual void Awake()
    {
        m_Transform = transform;
        m_Camera = vp_UIManager.GetUICamera(m_Transform) == null ? m_Transform.root.GetComponentInChildren<Camera>() : vp_UIManager.GetUICamera(m_Transform);
        m_Parent = m_Transform.parent;
        Manager = m_Transform.root.GetComponentInChildren<vp_UIManager>();
        m_LastFingerID = -1;
        if(GetComponent<Collider>() != null) m_Collider = GetComponents<BoxCollider>().FirstOrDefault();

        // Auto register events
        List<string> supportedButtonMethods = new List<string>(){ "OnPressControl", "OnHoldControl", "OnReleaseControl", "OnDoublePressControl", "OnDoubleReleaseControl" };
        List<string> supportedToggleMethods = new List<string>(){ "OnChangeControl" };

        List<MonoBehaviour> components = GetComponents<MonoBehaviour>().ToList();
        for(int i=0;i<components.Count; i++)
        {
            MonoBehaviour component = components[i];
            MethodInfo[] methodInfos = component.GetType().GetMethods( BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
            foreach(MethodInfo methodInfo in methodInfos)
            {
                if(methodInfo.GetParameters().Length == 0 && methodInfo.ReturnType == typeof(void))
                {
                    foreach(string methodName in supportedButtonMethods)
                        if(methodInfo.Name == methodName)
                            m_ButtonEvents.Add((vp_TouchButtonEventBinding)Delegate.CreateDelegate(typeof(vp_TouchButtonEventBinding), component, methodName));
                }
                else if(methodInfo.GetParameters().Length == 1 && methodInfo.GetParameters()[0].ParameterType == typeof(vp_UIControl) && methodInfo.ReturnType == typeof(void))
                {
                    foreach(string methodName in supportedToggleMethods)
                        if(methodInfo.Name == methodName)
                            m_ChangedEvents.Add((vp_TouchChangedEventBinding)Delegate.CreateDelegate(typeof(vp_TouchChangedEventBinding), component, methodName));
                }
            }
        }

        // setup changed events
        for(int i = 0; i<Objects.Count; i++)
        {
            if(Objects[i] == null || Methods[i] == "")
                continue;

            string[] info = Methods[i].Split(new string[1]{ "." }, System.StringSplitOptions.None);
            Component component = (Component)Objects[i].GetComponent(info[0]);
            if(component.GetType().GetMethod(info[1]).GetParameters().Length > 0)
                m_ChangedEvents.Add((vp_TouchChangedEventBinding)Delegate.CreateDelegate(typeof(vp_TouchChangedEventBinding), component, info[1]));
            else if(component.GetType().GetMethod(info[1]).GetParameters().Length == 0)
                m_ButtonEvents.Add((vp_TouchButtonEventBinding)Delegate.CreateDelegate(typeof(vp_TouchButtonEventBinding), component, info[1]));
        }
    }
Example #11
0
    protected vp_UIManager m_Manager = null;                              // cached vp_UIManager


    /// <summary>
    ///
    /// </summary>
    protected virtual void Awake()
    {
        m_Manager = transform.root.GetComponent <vp_UIManager>();
    }
Example #12
0
    protected bool m_Initialized = false;                                                    // initialization flag


    /// <summary>
    ///
    /// </summary>
    protected virtual void Awake()
    {
        m_Manager = GetComponent <vp_UIManager>();
        SetupButtons();
    }