示例#1
0
        /// <summary>
        /// Returns true if the step has references all the way to the root.
        /// </summary>
        /// <param name="instance">Instance to check</param>
        /// <param name="checkIfPropertyAccessed">Check if property has been accessed on the instance.</param>
        /// <returns></returns>
        internal bool IsReferencedToRoot(ModelInstance instance, bool checkIfPropertyAccessed)
        {
            // Exit immediately if the instance is not valid for the current step filter
            if (Filter != null && !Filter.IsInstanceOfType(instance))
            {
                return(false);
            }

            // Check if the current property has been accessed on the instance
            if (checkIfPropertyAccessed && !instance.HasBeenAccessed(Property))
            {
                return(false);
            }

            //if there's no previous steps then the step directly applies to the instance
            if (PreviousStep == null)
            {
                return(true);
            }

            //unless the previous step has references the step is not relevant to the instance.
            foreach (ModelReference parentReference in instance.GetInReferences((ModelReferenceProperty)PreviousStep.Property))
            {
                if (PreviousStep.IsReferencedToRoot(parentReference.In, false))
                {
                    return(true);
                }
            }

            return(false);
        }
 private void Initialize()
 {
     if (PreviousStep.Step != null)
     {
         newStep = PreviousStep.Clone();
         foreach (Transform child in newStep.Step.transform)
         {
             //Skip the HelpObject
             if (newStep.Help != null && child == newStep.Help.transform)
             {
                 continue;
             }
             components.Add(new InstructionStepComponent(child.gameObject));
         }
     }
     else
     {
         var prefab = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefabs/InstructionStep.prefab");
         newStep           = new InstructionStep(Instantiate(prefab), null);
         newStep.Step.name = prefab.name;
     }
     newStep.Step.SetActive(true);
     EditorGUIUtility.PingObject(newStep.Step);
     Selection.activeGameObject = newStep.Step;
     SceneView.lastActiveSceneView.FrameSelected();
     HelpObject  = newStep.Help;
     initialized = true;
 }
示例#3
0
        /// <summary>
        /// Set the view pager into which this wizard should load the steps
        /// </summary>
        /// <param name="viewPager"></param>
        public void SetViewPager(ViewPager viewPager)
        {
            ViewPager         = viewPager;
            ViewPager.Adapter = new WizardPagerAdapter(FragmentManager, WizardFlow, StateManager, this);

            //ViewPager.PageScrolled += (sender, e) => { };

            ViewPager.PageSelected += (sender, e) =>
            {
                if (FragmentManager.BackStackEntryCount < e.Position)
                {
                    FragmentManager.BeginTransaction().AddToBackStack(null).Commit();
                }
                else if (FragmentManager.BackStackEntryCount > e.Position)
                {
                    FragmentManager.PopBackStack();
                }
            };

            ViewPager.PageScrollStateChanged += (sender, e) =>
            {
                switch (e.State)
                {
                case ViewPager.ScrollStateDragging:     //Indicates that the pager is currently being dragged by the user.
                    PreviousPosition = ViewPager.CurrentItem;
                    PreviousStep     = CurrentStep;
                    break;

                case ViewPager.ScrollStateSettling:     //Indicates that the pager is in the process of settling to a final position.
                    if (StepChanged != null)
                    {
                        StepChanged();
                    }
                    break;

                case ViewPager.ScrollStateIdle:     //Indicates that the pager is in an idle, settled state.
                    if (PreviousState == ViewPager.ScrollStateSettling)
                    {
                        if (ViewPager.CurrentItem > PreviousPosition)
                        {
                            ProcessStepBeforeChange(PreviousStep, PreviousPosition);
                            ViewPager.Adapter.NotifyDataSetChanged();     //Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.
                        }
                        else
                        {
                            PreviousStep.OnExit(StepExitCode.ExitPrevious);
                        }
                    }
                    break;
                }

                PreviousState = e.State;
            };
        }
示例#4
0
        /// <summary>
        /// Recursively walks up the path the current step is a member of until the
        /// root is reached and then initiates path change notification events.
        /// </summary>
        /// <param name="instance"></param>
        internal void Notify(ModelInstance instance)
        {
            // Exit immediately if the instance is not valid for the current step filter
            if (Filter != null && !Filter.IsInstanceOfType(instance))
            {
                return;
            }

            // Keep walking if there are more tokens
            if (PreviousStep != null)
            {
                foreach (ModelReference parentReference in instance.GetInReferences((ModelReferenceProperty)PreviousStep.Property))
                {
                    PreviousStep.Notify(parentReference.In);
                }
            }
            // Otherwise, notify the path with the first instance instance
            else
            {
                Path.Notify(instance);
            }
        }