コード例 #1
0
    public NguiDataContext GetContext(string path)
    {
        NguiDataContext context = null;

        if (_contexts.TryGetValue(NguiUtils.GetPathDepth(path), out context))
        {
            return(context);
        }
        var depthToGo = NguiUtils.GetPathDepth(path);

        context = NguiUtils.FindRootContext(gameObject, depthToGo);
        if (context != null)
        {
            _contexts.Add(depthToGo, context);
        }
        return(context);
    }
コード例 #2
0
    public static NguiDataContext FindRootContext(GameObject gameObject, int depthToGo)
    {
        NguiDataContext lastGoodContext = null;
        var             p = gameObject;//.transform.parent == null ? null : gameObject.transform.parent.gameObject;

        depthToGo++;
        while (p != null && depthToGo > 0)
        {
            var context = p.GetComponent <NguiDataContext>();
            if (context != null)
            {
                lastGoodContext = context;
                depthToGo--;
            }
            p = (p.transform.parent == null) ? null : p.transform.parent.gameObject;
        }
        return(lastGoodContext);
    }
コード例 #3
0
	private void Bind(NguiDataContext context)
	{
		_v3property = context.FindProperty<Vector3>(Path, this);
		if (_v3property != null)
		{
			_v3property.OnChange += OnChange;
			return;
		}
		
		_v2property = context.FindProperty<Vector2>(Path, this);
		if (_v2property != null)
		{
			_v2property.OnChange += OnChange;
			return;
		}
		
		_t2property = context.FindProperty<Texture2D>(Path, this);
		if (_t2property != null)
		{
			_t2property.OnChange += OnChange;
			return;
		}
		
		_transformProperty = context.FindProperty<Transform>(Path, this);
		if (_transformProperty != null)
		{
			_transformProperty.OnChange += OnChange;
			return;
		}
		
		_componentProperty = context.FindProperty<Component>(Path, this);
		if (_componentProperty != null)
		{
			_componentProperty.OnChange += OnChange;
			return;
		}

		_gameObjectProperty = context.FindProperty<GameObject>(Path, this);
		if (_gameObjectProperty != null)
		{
			_gameObjectProperty.OnChange += OnChange;
			return;
		}
	}
コード例 #4
0
    public void Bind(NguiDataContext context)
    {
        _v3property = context.FindProperty <Vector3>(Path, this);
        if (_v3property != null)
        {
            _v3property.OnChange += OnChange;
            return;
        }

        _v2property = context.FindProperty <Vector2>(Path, this);
        if (_v2property != null)
        {
            _v2property.OnChange += OnChange;
            return;
        }

        _t2property = context.FindProperty <Texture2D>(Path, this);
        if (_t2property != null)
        {
            _t2property.OnChange += OnChange;
            return;
        }

        _transformProperty = context.FindProperty <Transform>(Path, this);
        if (_transformProperty != null)
        {
            _transformProperty.OnChange += OnChange;
            return;
        }

        _componentProperty = context.FindProperty <Component>(Path, this);
        if (_componentProperty != null)
        {
            _componentProperty.OnChange += OnChange;
            return;
        }

        _gameObjectProperty = context.FindProperty <GameObject>(Path, this);
        if (_gameObjectProperty != null)
        {
            _gameObjectProperty.OnChange += OnChange;
            return;
        }
    }