示例#1
0
        public void BuildNavigation(SelectableGroup group)
        {
            Vector3 position;
            Vector3 direction;
            Vector3 localDir;
            float   maxScore;

            foreach (SelectableOptionBase option in group.options)
            {
                Transform transform = option.GetTransform();

                for (int i = 0; i < option.navigationArray.Length; i++)
                {
                    maxScore = Mathf.NegativeInfinity;

                    direction = SelectableNavigationUtils.GetDirectionVector((SelectableNavigationDirection)i);
                    localDir  = Quaternion.Inverse(transform.rotation) * direction;
                    position  = transform.TransformPoint(SelectableNavigationUtils.GetPointOnRectEdge(transform as RectTransform, localDir));

                    SelectableOptionBase bestPick = null;
                    foreach (SelectableOptionBase other in group.options)
                    {
                        SelectableOptionBase sel = other;

                        if (sel == option || sel == null)
                        {
                            continue;
                        }

                        var     selRect   = sel.GetTransform() as RectTransform;
                        Vector3 selCenter = selRect != null ? (Vector3)selRect.rect.center : Vector3.zero;
                        Vector3 myVector  = sel.GetTransform().TransformPoint(selCenter) - position;

                        // Value that is the distance out along the direction.
                        float dot = Vector3.Dot(direction, myVector);

                        // Skip elements that are in the wrong direction or which have zero or too much distance.
                        // This also ensures that the scoring formula below will not have a division by zero error.
                        if (dot <= 0)
                        {
                            continue;
                        }

                        // This scoring function has two priorities:
                        // - Score higher for positions that are closer.
                        // - Score higher for positions that are located in the right direction.
                        // This scoring function combines both of these criteria.
                        float score = dot / myVector.sqrMagnitude;

                        if (score > maxScore)
                        {
                            maxScore = score;
                            bestPick = sel;
                        }
                    }

                    option.navigationArray[i] = bestPick;
                }
            }
        }
 private void Start()
 {
     _selectableGroup = GetComponent <SelectableGroup>();
     if (_selectableGroup == null)
     {
         Debug.LogError("Reproduction menu must have a SelectableGroup component");
     }
 }
示例#3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            Group group = db.Groups.Find(id);

            if (group == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Groups = SelectableGroup.Convert(FillWithChildren(db.Groups.Where(p => p.Parent == null && p.ID != group.ID).ToList(), group.ID));
            return(View(group));
        }
示例#4
0
        public void BuildNavigation(SelectableGroup group)
        {
            List <SelectableOptionBase> sortedOptions;

            if (axis == SORTING_AXIS.X)
            {
                sortedOptions = SelectableNavigationUtils.SortByXPosFirst(group.options);
            }
            else if (axis == SORTING_AXIS.Y)
            {
                sortedOptions = SelectableNavigationUtils.SortByYPosFirst(group.options);
            }
            else
            {
                //Use as a fallback if no axis is set
                sortedOptions = group.options;
            }

            SelectableNavigationUtils.BuildNavigationFromSortedList(sortedOptions, group.navigationType);
        }
示例#5
0
 public void BuildNavigation(SelectableGroup group)
 {
     SelectableNavigationUtils.BuildNavigationFromSortedList(group.options, group.navigationType);
 }
示例#6
0
 public void BuildNavigation(SelectableGroup group)
 {
     BuildSmartNavigation(SelectableNavigationUtils.SortByYPosFirst(group.options), maxSearchDistances);
 }
 private void OnEnable()
 {
     group               = (SelectableGroup)target;
     group.options       = group.GetComponentsInChildren <SelectableOptionBase>().ToList();
     maxRaycastDistances = new float[4];
 }
示例#8
0
 public ActionResult Create()
 {
     ViewBag.Groups = SelectableGroup.Convert(FillWithChildren(db.Groups.Where(p => p.Parent == null).ToList()));
     return(View());
 }
示例#9
0
 public ActionResult Index()
 {
     return(View(SelectableGroup.Convert(FillWithChildren(db.Groups.Where(p => p.Parent == null).ToList()))));
 }