Пример #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public override void OnInspectorGUI()
        {
            TreeUpdater targ       = (TreeUpdater)target;
            int         upsCount   = targ.TreeUpdatablesThisFrame.Count;
            int         childCount = targ.TreeChildrenThisFrame.Count;

            DrawDefaultInspector();

            GUI.enabled = false;

            EditorGUILayout.ObjectField("Parent", targ.TreeParentThisFrame, typeof(TreeUpdater), true);
            EditorGUILayout.IntField("Depth Level", targ.TreeDepthLevelThisFrame);

            vShowUpdatables = EditorGUILayout.Foldout(
                vShowUpdatables, "Updatable Components (" + upsCount + ")");

            for (int i = 0; vShowUpdatables && i < upsCount; i++)
            {
                EditorGUILayout.TextField("    Component " + i,
                                          targ.gameObject.name + " (" + targ.TreeUpdatablesThisFrame[i].GetType().Name + ")");
            }

            vShowChildren = EditorGUILayout.Foldout(
                vShowChildren, "Children (" + childCount + ")");

            for (int i = 0; vShowChildren && i < childCount; i++)
            {
                EditorGUILayout.ObjectField("    Child " + i,
                                            targ.TreeChildrenThisFrame[i], typeof(TreeUpdater), true);
            }

            GUI.enabled = true;
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateShapeArcChildren()
        {
            if (!ControlChildShapes)
            {
                return;
            }

            TreeUpdater tree = GetComponent <TreeUpdater>();

            for (int i = 0; i < tree.TreeChildrenThisFrame.Count; i++)
            {
                TreeUpdater   child    = tree.TreeChildrenThisFrame[i];
                HoverShapeArc childArc = child.GetComponent <HoverShapeArc>();

                if (childArc == null)
                {
                    continue;
                }

                Quaternion offsetRot = Quaternion.Inverse(childArc.transform.localRotation);

                childArc.Controllers.Set(OuterRadiusName, this);
                childArc.Controllers.Set(InnerRadiusName, this);
                childArc.Controllers.Set(ArcDegreesName, this);
                childArc.Controllers.Set(OuterOffsetName, this);
                childArc.Controllers.Set(InnerOffsetName, this);

                childArc.OuterRadius = OuterRadius;
                childArc.InnerRadius = InnerRadius;
                childArc.ArcDegrees  = ArcDegrees;
                childArc.OuterOffset = offsetRot * OuterOffset;
                childArc.InnerOffset = offsetRot * InnerOffset;
            }
        }
        /*--------------------------------------------------------------------------------------------*/
        private void BuildCursor(HoverCursorDataProvider pProv, ICursorData pData)
        {
            var curGo = new GameObject(pData.Type + "");

            curGo.transform.SetParent(gameObject.transform, false);

            TreeUpdater treeUp = curGo.AddComponent <TreeUpdater>();

            HoverCursorFollower follow = curGo.AddComponent <HoverCursorFollower>();

            follow.CursorDataProvider   = pProv;
            follow.CursorType           = pData.Type;
            follow.FollowCursorActive   = false;
            follow.ScaleUsingCursorSize = true;

            HoverCursorRendererUpdater cursRendUp = curGo.AddComponent <HoverCursorRendererUpdater>();

            cursRendUp.CursorRendererPrefab = CursorRendererPrefab;

            if (pData.Idle != null)
            {
                HoverIdleRendererUpdater idleRendUp = curGo.AddComponent <HoverIdleRendererUpdater>();
                idleRendUp.IdleRendererPrefab = IdleRendererPrefab;
            }

            follow.Update();                    //moves interface to the correct cursor transform
            treeUp.UpdateAtAndBelowThisLevel(); //force renderer creation
        }
Пример #4
0
    void Start()
    {
        // Stores the name:
        _name = gameObject.name;

        // Getting the Tree Updater script:
        _refTreeUpdater = GameObject.FindWithTag("Platform").GetComponent <TreeUpdater>();

        // Getting the Metal script:
        _metal = GetComponent <Metal>();

        // Getting the thermo features:
        Thermo_Features tf = GetComponent <Thermo_Features>();

        _d         = tf.GetD();
        _deltaT    = tf.deltaT;
        _Tatm      = tf.Tatm;
        _c         = tf.GetC();
        delta_r_H0 = tf.Getdeltar_H();
        _h         = tf.GetH();

        // initially everything temperature is equal to Tatm
        T    = _Tatm;
        Tnew = _Tatm;

        // We get the neighbors of the current visited  Voxel
        neighbors = gameObject.GetComponent <Voxel>().voxelNeighbors;
    }
Пример #5
0
        /*--------------------------------------------------------------------------------------------*/
        private static T BuildRenderer <T>(Transform pParentTx, GameObject pPrefab,
                                           string pDisplayTypeName, Type pDefaultType) where T : class, IGameObjectProvider
        {
            if (pPrefab != null)
            {
                T prefabRend = TryBuildPrefabRenderer <T>(pPrefab);

                if (prefabRend != null)
                {
                    prefabRend.gameObject.transform.SetParent(pParentTx, false);

                    TreeUpdater treeUp = prefabRend.gameObject.GetComponent <TreeUpdater>();

                    if (treeUp != null)
                    {
                        treeUp.Update();
                    }

                    return(prefabRend);
                }

                Debug.LogError(pDisplayTypeName + " prefab '" + pPrefab.name + "' must contain a '" +
                               typeof(T) + "' component. ", pParentTx);
            }

            Debug.LogWarning("Could not find existing renderer, and no prefab provided.", pParentTx);
            return(default(T));
        }
Пример #6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateShapeRectChildren()
        {
            if (!ControlChildShapes)
            {
                return;
            }

            TreeUpdater tree = GetComponent <TreeUpdater>();

            for (int i = 0; i < tree.TreeChildrenThisFrame.Count; i++)
            {
                TreeUpdater    child     = tree.TreeChildrenThisFrame[i];
                HoverShapeRect childRect = child.GetComponent <HoverShapeRect>();

                if (childRect == null)
                {
                    continue;
                }

                childRect.Controllers.Set(SizeXName, this);
                childRect.Controllers.Set(SizeYName, this);

                childRect.SizeX = SizeX;
                childRect.SizeY = SizeY;
            }
        }
Пример #7
0
 /*--------------------------------------------------------------------------------------------*/
 public void ReleaseSelectionPrevention()
 {
     if (IsSelectionPrevented)
     {
         IsSelectionPrevented = false;
         TreeUpdater.SendTreeUpdatableChanged(this, "ReleaseSelectionPrevent");
     }
 }
Пример #8
0
    // ------------------ Awake and Update function --------------- //

    void Awake()
    {
        // Getting the Tree Updater script:
        _refTreeUpdater = GameObject.FindWithTag("Platform").GetComponent <TreeUpdater>();


        this.k = 1000f;
        this.alphaTranslation     = 10f;
        this.breakingDistanceCoef = 1.1f;
    }
Пример #9
0
        /*--------------------------------------------------------------------------------------------*/
        public virtual void DeselectStickySelections()
        {
            if (!IsStickySelected)
            {
                return;
            }

            IsStickySelected = false;
            TreeUpdater.SendTreeUpdatableChanged(this, "IsStickySelected");
            OnDeselected(this);
        }
Пример #10
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void PerformBuild()
        {
            TreeUpdater         treeUp    = gameObject.AddComponent <TreeUpdater>();
            HoverShapeRect      shapeRect = gameObject.AddComponent <HoverShapeRect>();
            HoverpanelInterface inter     = gameObject.AddComponent <HoverpanelInterface>();

            ////

            treeUp.enabled = false;

            var row0Go = new GameObject("RowRoot");

            row0Go.transform.SetParent(gameObject.transform, false);
            BuildRow(row0Go);

            if (IncludeExampleRows)
            {
                BuildExampleRows(row0Go);
            }

            treeUp.enabled = true;

            ////

            shapeRect.SizeX = 0.3f;
            shapeRect.SizeY = 0.2f;

            inter.ActiveRow = row0Go.GetComponent <HoverLayoutRectRow>();

            gameObject.AddComponent <HoverpanelRowSizer>();

            HoverpanelRowTransitioner rowTrans = gameObject.AddComponent <HoverpanelRowTransitioner>();

            rowTrans.RowEntryTransition = HoverpanelRowSwitchingInfo.RowEntryType.SlideFromTop;

#if UNITY_EDITOR
            UnityEditor.Events.UnityEventTools.AddPersistentListener(
                inter.OnRowSwitchedEvent, rowTrans.OnRowSwitched);
#else
            inter.OnRowSwitchedEvent.AddListener(rowTrans.OnRowSwitched);
#endif

            gameObject.AddComponent <HoverpanelHighlightPreventer>();
            gameObject.AddComponent <HoverpanelActiveDirection>();
            gameObject.AddComponent <HoverpanelAlphaUpdater>();

            treeUp.Update();             //forces entire interface to update
        }
Пример #11
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void PerformBuild()
        {
            gameObject.AddComponent <HoverkeyInterface>();
            gameObject.AddComponent <HoverkeyTextInput>();

            BuildMain();
            BuildFunctions();
            BuildThree();
            BuildSix();
            BuildArrows();
            BuildNumpad();

            TreeUpdater treeUp = gameObject.AddComponent <TreeUpdater>();

            treeUp.Update();                 //force entire interface update
            DestroyImmediate(treeUp, false); //remove the updater
        }
Пример #12
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void PerformBuild()
        {
            TreeUpdater treeUp = gameObject.AddComponent <TreeUpdater>();

            HoverItem item = gameObject.AddComponent <HoverItem>();

            item.ItemType = ItemType;

            HoverItemHighlightState highState = gameObject.AddComponent <HoverItemHighlightState>();

            gameObject.AddComponent <HoverItemSelectionState>();

            HoverItemRendererUpdater rendUp = gameObject.AddComponent <HoverItemRendererUpdater>();

            rendUp.ButtonRendererPrefab = ButtonRendererPrefab;
            rendUp.SliderRendererPrefab = SliderRendererPrefab;
            highState.ProximityProvider = rendUp;

            treeUp.Update();             //forces the entire item to update
        }
Пример #13
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateIndicatorChildren()
        {
            TreeUpdater tree = GetComponent <TreeUpdater>();

            for (int i = 0; i < tree.TreeChildrenThisFrame.Count; i++)
            {
                TreeUpdater    child    = tree.TreeChildrenThisFrame[i];
                HoverIndicator childInd = child.GetComponent <HoverIndicator>();

                if (childInd == null)
                {
                    continue;
                }

                childInd.Controllers.Set(HighlightProgressName, this);
                childInd.Controllers.Set(SelectionProgressName, this);

                childInd.HighlightProgress   = HighlightProgress;
                childInd.SelectionProgress   = SelectionProgress;
                childInd.LatestSelectionTime = LatestSelectionTime;
            }
        }
Пример #14
0
        private void UpdateTree()
        {
            TreeUpdater updater = new TreeUpdater(_component.Pages, _treeView.Nodes);

            _nodeMap = updater.UpdateTree();
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void PerformBuild()
        {
            TreeUpdater         treeUp = gameObject.AddComponent <TreeUpdater>();
            HoverCursorFollower follow = gameObject.AddComponent <HoverCursorFollower>();
            HovercastInterface  inter  = gameObject.AddComponent <HovercastInterface>();

            ////

            var adjustGo = new GameObject("TransformAdjuster");

            adjustGo.transform.SetParent(transform, false);
            adjustGo.transform.localPosition = new Vector3(0, 0, 0.02f);
            adjustGo.transform.localRotation = Quaternion.Euler(0, 180, 80);

            var openItemGo = new GameObject("OpenItem");

            openItemGo.transform.SetParent(adjustGo.transform, false);
            openItemGo.transform.localPosition = new Vector3(0, -0.05f, 0);

            var titleItemGo = new GameObject("TitleItem");

            titleItemGo.transform.SetParent(adjustGo.transform, false);

            var backItemGo = new GameObject("BackItem");

            backItemGo.transform.SetParent(adjustGo.transform, false);

            var rowContGo = new GameObject("Rows");

            rowContGo.transform.SetParent(adjustGo.transform, false);
            rowContGo.AddComponent <TreeUpdater>();

            var row0Go = new GameObject("Root");

            row0Go.transform.SetParent(rowContGo.transform, false);

            ////

            BuildOpenItem(openItemGo);
            BuildTitleItem(titleItemGo);
            BuildBackItem(backItemGo);
            BuildRow(row0Go, "Hovercast");

            if (IncludeExampleRows)
            {
                BuildExampleRows(rowContGo, row0Go);
            }

            adjustGo.AddComponent <TreeUpdater>();            //after building items

            ////

            follow.CursorType        = (AttachToLeftHand ? CursorType.LeftPalm : CursorType.RightPalm);
            follow.ObjectsToActivate = new[] { openItemGo, titleItemGo, backItemGo, rowContGo };

            inter.RowContainer = rowContGo.transform;
            inter.ActiveRow    = row0Go.GetComponent <HoverLayoutArcRow>();
            inter.OpenItem     = openItemGo.GetComponent <HoverItemDataSelector>();
            inter.TitleItem    = titleItemGo.GetComponent <HoverItemDataText>();
            inter.BackItem     = backItemGo.GetComponent <HoverItemDataSelector>();

            HovercastOpenTransitioner openTrans = gameObject.AddComponent <HovercastOpenTransitioner>();

            HovercastRowTransitioner rowTrans = gameObject.AddComponent <HovercastRowTransitioner>();

            rowTrans.RowEntryTransition = HovercastRowSwitchingInfo.RowEntryType.FromInside;

#if UNITY_EDITOR
            UnityEditor.Events.UnityEventTools.AddPersistentListener(
                inter.OnOpenToggledEvent, openTrans.OnOpenToggled);
            UnityEditor.Events.UnityEventTools.AddPersistentListener(
                inter.OnRowSwitchedEvent, rowTrans.OnRowSwitched);
#else
            inter.OnOpenToggledEvent.AddListener(openTrans.OnOpenToggled);
            inter.OnRowSwitchedEvent.AddListener(rowTrans.OnRowSwitched);
#endif

            gameObject.AddComponent <HovercastHighlightPreventer>();

            HovercastBackCursorTrigger backTrig = gameObject.AddComponent <HovercastBackCursorTrigger>();
            backTrig.BackTriggerCursorType = follow.CursorType;

            HovercastActiveDirection actDir = gameObject.AddComponent <HovercastActiveDirection>();
            actDir.ChildForActivation = adjustGo;

            HovercastMirrorSwitcher mirror = gameObject.AddComponent <HovercastMirrorSwitcher>();
            mirror.UseMirrorLayout = !AttachToLeftHand;

            gameObject.AddComponent <HovercastAlphaUpdater>();

            if (AutoRotateHandToFaceCamera)
            {
                HoverCursorDataProvider curDataProv = FindObjectOfType <HoverCursorDataProvider>();
                ICursorDataForInput     curData     = curDataProv.GetCursorDataForInput(follow.CursorType);
                float addRotZ = 80 * (AttachToLeftHand ? 1 : -1);

                actDir.TreeUpdate();                 //forces search for the "facing" transform
                curData.transform.LookAt(actDir.ActiveWhenFacingTransform, Vector3.up);
                curData.transform.localRotation *= Quaternion.Euler(0, 0, addRotZ);
            }

            follow.Update();             //moves interface to the correct cursor transform
            treeUp.Update();             //forces entire interface to update
        }
 private void UpdateTree()
 {
     TreeUpdater updater = new TreeUpdater(_component.Pages, _treeView.Nodes);
     _nodeMap = updater.UpdateTree();
 }