Example #1
0
        private void VerifyCursorState(IMixedRealityCursor cursor, CursorStateEnum state)
        {
            var baseCursor = cursor as BaseCursor;

            Assert.IsNotNull(baseCursor);
            Assert.AreEqual(state, baseCursor.CursorState);
        }
Example #2
0
        /// <summary>
        /// Internal update to check for cursor state changes
        /// </summary>
        private void UpdateCursorState()
        {
            CursorStateEnum newState = CheckCursorState();

            if (cursorState != newState)
            {
                OnCursorStateChange(newState);
            }
        }
Example #3
0
    /// <summary>
    /// Override OnCursorState change to set the correct object state for the cursor
    /// </summary>
    public override void OnCursorStateChange(CursorStateEnum state)
    {
        base.OnCursorStateChange(state);
        if (state != CursorStateEnum.Contextual)
        {
            //// First, try to find a cursor for the current state
            var  newActive           = new ObjectCursorDatum();
            bool newStateCursorFound = cursorStatesDict.TryGetValue(state, out newActive);

            // if not found, just show the last active cursor object
            if (!newStateCursorFound)
            {
                return;
            }

            // hide the last active cursor
            if (lastActiveCursorObj != null)
            {
                lastActiveCursorObj.SetActive(false);
            }

            lastActiveCursorObj = newActive.CursorObject;
            newActive.CursorObject.SetActive(true);

            // cursorstate does NOT change if going from building => map (still observeHover)
            // targeted object is NOT updated until the state changes => use GazeManager.HitObject

            if (isDrawing)
            {
                GameObject hitObject = GazeManager.Instance.HitObject;
                if (hitObject != null)
                {
                    if (hitObject.name == GameObjectNamesHolder.NAME_MAP_COLLIDER)
                    {
                        if (newActive.CursorState == CursorStateEnum.ObserveHover)
                        {
                            newActive.CursorObject.SetActive(false);
                        }
                        ShowPointCursor();
                        return; // note that this is return
                    }
                    else if (hitObject.name.Contains("Point"))
                    {
                        //This is for the first-drawn-point object
                        HidePointCursor();
                        if (newActive.CursorState == CursorStateEnum.ObserveHover)
                        {
                            newActive.CursorObject.SetActive(false);
                        }
                        return;
                    }
                }
                HidePointCursor();
            }
        }
    }
        public override void OnCursorStateChange(CursorStateEnum state)
        {
            base.OnCursorStateChange(state);

            if (mHasHand != this.IsHandVisible || mIsDown != this.IsInputSourceDown || mHasHover != (this.TargetedObject != null))
            {
                mTimer = 0;
            }

            mHasHand  = this.IsHandVisible;
            mIsDown   = this.IsInputSourceDown;
            mHasHover = this.TargetedObject != null;

            mTargetScale = mBaseScale * DefaultScale;
            bool showRing = false;

            switch (state)
            {
            case CursorStateEnum.None:
                break;

            case CursorStateEnum.Observe:
                break;

            case CursorStateEnum.ObserveHover:
                showRing = true;
                break;

            case CursorStateEnum.Interact:
                showRing     = true;
                mTargetScale = mBaseScale * DownScale;
                break;

            case CursorStateEnum.InteractHover:
                showRing     = true;
                mTargetScale = mBaseScale * UpScale;
                break;

            case CursorStateEnum.Select:
                mTargetScale = mBaseScale * UpScale;
                break;

            case CursorStateEnum.Release:
                break;

            case CursorStateEnum.Contextual:
                break;

            default:
                break;
            }

            Ring.SetActive(showRing);
            Dot.SetActive(!showRing);
        }
        public override void OnCursorStateChange(CursorStateEnum state)
        {
            GameObject gazedObject = null;

            if (GazeManager.IsInitialized)
            {
                gazedObject = GazeManager.Instance.HitObject;
            }

            UpdateCursor(state, gazedObject);
        }
 /// <summary>
 /// Override OnCursorState change to set the correct animation
 /// state for the cursor
 /// </summary>
 /// <param name="state"></param>
 public override void OnCursorStateChange(CursorStateEnum state)
 {
     base.OnCursorStateChange(state);
     if (state != CursorStateEnum.Contextual)
     {
         for (int i = 0; i < CursorStateData.Length; i++)
         {
             if (CursorStateData[i].CursorState == state)
             {
                 SetAnimatorParameter(CursorStateData[i].Parameter);
             }
         }
     }
 }
 /// <summary>
 /// Override OnCursorState change to set the correct animation
 /// state for the cursor
 /// </summary>
 /// <param name="state"></param>
 public override void OnCursorStateChange(CursorStateEnum state)
 {
     base.OnCursorStateChange(state);
     if(state != CursorStateEnum.Contextual)
     {
         for(int i = 0; i < CursorStateData.Length; i++)
         {
             if(CursorStateData[i].CursorState == state)
             {
                 SetCursorState(CursorStateData[i]);
             }
         }
     }
 }
Example #8
0
        /// <summary>
        /// Internal update to check for cursor state changes
        /// </summary>
        private void UpdateCursorState()
        {
            CursorStateEnum newState = CheckCursorState();

            if (CursorState != newState)
            {
                OnCursorStateChange(newState);
            }

            CursorContextEnum newContext = CheckCursorContext();

            if (CursorContext != newContext)
            {
                OnCursorContextChange(newContext);
            }
        }
Example #9
0
    // Update is called once per frame
    void Update()
    {
        NowCursorState = tmpCursor.GetComponent <AnimatedCursor>().tmpCursorState;

        PlaceBtnState  = PlaceButton.GetComponent <ButtonInteraction>().NowButtonState;
        DeleteBtnState = DeleteButton.GetComponent <ButtonInteraction>().NowButtonState;
        CancelBtnState = CancelButton.GetComponent <ButtonInteraction>().NowButtonState;


        lineRenderer = GetComponent <LineRenderer>();

        //Debug.Log("Cursor Position: " + tmpCursor.transform.position);

        //Vector3 CursorPosition = tmpCursor.GetComponent<Transform>().position;

        if ((ButtonInteraction.PosState == PosButtonType.PLACE) && (NowCursorState == CursorStateEnum.Release) &&
            (PlaceBtnState != ButtonStateEnum.Targeted) && (PlaceBtnState != ButtonStateEnum.Pressed) &&
            (DeleteBtnState != ButtonStateEnum.Observation) && (CancelBtnState != ButtonStateEnum.Observation))
        {
            Instantiate(PlaneObject, tmpCursor.transform.position, transform.rotation, this.transform);

            //WayPoint.Add(tmp);
            Debug.Log("InstantiateInstantiateInstantiateInstantiateInstantiateInstantiate");
        }


        ChildCount = this.transform.childCount;
        lineRenderer.SetVertexCount(ChildCount);


        if (ChildCount > 1)
        {
            for (int i = 0; i < ChildCount; i++)
            {
                tmp = this.gameObject.transform.GetChild(i).gameObject;
                lineRenderer.SetPosition(i, tmp.transform.position);
            }
        }

        //if(ChildCount == 2) lineRenderer.SetPosition(2, new Vector3(0,0,1));
    }
Example #10
0
    void ChangeCursorState(CursorStateEnum newState)
    {
        if (cursorState != newState)
        {
            switch (newState)
            {
            case CursorStateEnum.findBugNormal:
                Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.Auto);
                break;

            case CursorStateEnum.findBugHit:
                Cursor.SetCursor(cursorTextureHit, Vector2.zero, CursorMode.Auto);
                break;

            case CursorStateEnum.playMode:
                Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
                break;
            }
            cursorState = newState;
        }
    }
        /// <summary>
        /// Override OnCursorState change to set the correct animation
        /// state for the cursor
        /// </summary>
        /// <param name="state"></param>
        public override void OnCursorStateChange(CursorStateEnum state)
        {
            base.OnCursorStateChange(state);
            if (state != CursorStateEnum.Contextual)
            {
                // First, try to find a cursor for the current state
                var newActive = new ObjectCursorDatum();
                for (int cursorIndex = 0; cursorIndex < CursorStateData.Length; cursorIndex++)
                {
                    ObjectCursorDatum cursor = CursorStateData[cursorIndex];
                    if (cursor.CursorState == state)
                    {
                        newActive = cursor;
                        break;
                    }
                }

                // If no cursor for current state is found, let the last active cursor be
                // (any cursor is better than an invisible cursor)
                if (newActive.Name == null)
                {
                    //return;
                }

                // If we come here, there is a cursor for the new state,
                // so de-activate a possible earlier active cursor
                for (int cursorIndex = 0; cursorIndex < CursorStateData.Length; cursorIndex++)
                {
                    ObjectCursorDatum cursor = CursorStateData[cursorIndex];
                    if (cursor.CursorObject.activeSelf)
                    {
                        cursor.CursorObject.SetActive(false);
                        break;
                    }
                }

                // ... and set the cursor for the new state active.
                newActive.CursorObject.SetActive(true);
            }
        }
        /// <summary>
        /// Override OnCursorState change to set the correct animation
        /// state for the cursor
        /// </summary>
        /// <param name="state"></param>
        public override void OnCursorStateChange(CursorStateEnum state)
        {
            base.OnCursorStateChange(state);

            if (state != CursorStateEnum.Contextual)
            {
                // Hide all children first
                for(int i = 0; i < ParentTransform.childCount; i++)
                {
                    ParentTransform.GetChild(i).gameObject.SetActive(false);
                }

                // Set active any that match the current state
                for (int i = 0; i < CursorStateData.Length; i++)
                {
                    if (CursorStateData[i].CursorState == state)
                    {
                        CursorStateData[i].CursorObject.SetActive(true);
                    }
                }
            }
        }
        private void UpdateCursor(CursorStateEnum state, GameObject gazedObject)
        {
            if (state == CursorStateEnum.Select && cursorLockedObject == null)
            {
                cursorLockedObject = gazedObject;
            }
            else if (state == CursorStateEnum.Release)
            {
                cursorLockedObject = null;
            }

            base.OnCursorStateChange(state);

            // 1. For any game objects with tag `Interactable` the base class knows how to deal with them
            // so we won't do anything.
            // 2. If we have a game object under cursor lock, then we won't show our custom cursor icons,
            // instead we'll let the parent class show the `Select` state icon.
            if ((gazedObject != null && gazedObject.tag != TagsHelper.InteractableTag) && cursorLockedObject == null)
            {
                SetCursorWithName(gazedObject.tag);
            }
        }
Example #14
0
        /// <summary>
        /// Override OnCursorState change to set the correct animation
        /// state for the cursor
        /// </summary>
        /// <param name="state"></param>
        public override void OnCursorStateChange(CursorStateEnum state)
        {
            base.OnCursorStateChange(state);

            if (state != CursorStateEnum.Contextual)
            {
                // Hide all children first
                for (int i = 0; i < ParentTransform.childCount; i++)
                {
                    ParentTransform.GetChild(i).gameObject.SetActive(false);
                }

                // Set active any that match the current state
                for (int i = 0; i < CursorStateData.Length; i++)
                {
                    if (CursorStateData[i].CursorState == state)
                    {
                        CursorStateData[i].CursorObject.SetActive(true);
                    }
                }
            }
        }
Example #15
0
        /// <summary>
        /// Override OnCursorState change to set the correct animation state for the cursor.
        /// </summary>
        public void OnCursorStateChange(CursorStateEnum state)
        {
            CursorState     = state;
            scaleSmoothTime = 0f;
            switch (state)
            {
            case CursorStateEnum.Observe:
            case CursorStateEnum.ObserveHover:
            case CursorStateEnum.Interact:
            case CursorStateEnum.InteractHover:
                scaleTarget = 1f;
                scaleOrigin = 0f;
                break;

            case CursorStateEnum.None:
            case CursorStateEnum.Release:
            case CursorStateEnum.Contextual:
            default:
                scaleTarget = 0f;
                scaleOrigin = PrimaryCursorVisual.localScale.x / startScale.x;
                break;
            }
        }
Example #16
0
    /// <summary>
    /// On enable look for a sprite renderer on children
    /// </summary>
    protected override void OnEnable()
    {
        if (ParentTransform == null)
        {
            ParentTransform = transform;
        }

        for (int i = 0; i < ParentTransform.childCount; i++)
        {
            ParentTransform.GetChild(i).gameObject.SetActive(false);
        }

        base.OnEnable();

        // initialize dictionary
        for (int i = 0; i < CursorStateData.Length; i++)
        {
            CursorStateEnum stateName = CursorStateData[i].CursorState;
            cursorStatesDict[stateName] = CursorStateData[i];
        }

        isDrawing = false;
    }
Example #17
0
 /// <summary>
 /// Change the cursor state to the new state.  Override in cursor implementations.
 /// </summary>
 /// <param name="state"></param>
 public virtual void OnCursorStateChange(CursorStateEnum state)
 {
     cursorState = state;
 }
        /// <summary>
        /// Decide which element (ring or dot) should be visible and at what scale
        /// </summary>
        /// <param name="state"></param>
        public override void OnCursorStateChange(CursorStateEnum state)
        {
            base.OnCursorStateChange(state);

            // the cursor state has changed, reset the animation timer
            if (hasHand != IsSourceDetected || isDown != IsPointerDown || hasHover != (TargetedObject != null))
            {
                timer = 0;
            }

            hasHand  = IsSourceDetected;
            isDown   = IsPointerDown;
            hasHover = TargetedObject != null;

            targetScale = Vector3.one * defaultScale;
            bool showRing = false;

            switch (state)
            {
            case CursorStateEnum.None:
                break;

            case CursorStateEnum.Observe:
                break;

            case CursorStateEnum.ObserveHover:
                showRing = true;
                break;

            case CursorStateEnum.Interact:
                showRing    = true;
                targetScale = Vector3.one * downScale;
                break;

            case CursorStateEnum.InteractHover:
                showRing    = true;
                targetScale = Vector3.one * upScale;
                break;

            case CursorStateEnum.Select:
                targetScale = Vector3.one * upScale;
                break;

            case CursorStateEnum.Release:
                break;

            case CursorStateEnum.Contextual:
                break;
            }

            if (!isVisible)
            {
                return;
            }

            ring.SetActive(showRing);
            dot.SetActive(!showRing);

            // added observation of CursorModifier
            if (Pointer.CursorModifier != null && hasHover)
            {
                ElementVisibility(!Pointer.CursorModifier.GetCursorVisibility());
            }
        }
        /// <summary>
        /// Decide which element (ring or dot) should be visible and at what scale
        /// </summary>
        /// <param name="state"></param>
        public override void OnCursorStateChange(CursorStateEnum state)
        {
            base.OnCursorStateChange(state);

            // the cursor state has changed, reset the animation timer
            if (mHasHand != this.IsHandVisible || mIsDown != this.IsInputSourceDown || mHasHover != (this.TargetedObject != null))
            {
                mTimer = 0;
            }

            mHasHand  = this.IsHandVisible;
            mIsDown   = this.IsInputSourceDown;
            mHasHover = this.TargetedObject != null;

            mTargetScale = mBaseScale * DefaultScale;
            bool showRing = false;

            switch (state)
            {
            case CursorStateEnum.None:
                break;

            case CursorStateEnum.Observe:
                break;

            case CursorStateEnum.ObserveHover:
                showRing = true;
                break;

            case CursorStateEnum.Interact:
                showRing     = true;
                mTargetScale = mBaseScale * DownScale;
                break;

            case CursorStateEnum.InteractHover:
                showRing     = true;
                mTargetScale = mBaseScale * UpScale;
                break;

            case CursorStateEnum.Select:
                mTargetScale = mBaseScale * UpScale;
                break;

            case CursorStateEnum.Release:
                break;

            case CursorStateEnum.Contextual:
                break;

            default:
                break;
            }

            if (!mIsVisible)
            {
                return;
            }

            Ring.SetActive(showRing);
            Dot.SetActive(!showRing);

            // added observation of CursorModifier
            if (TargetedCursorModifier != null && mHasHover)
            {
                ElementVisibility(!TargetedCursorModifier.GetCursorVisibility());
            }
        }
Example #20
0
 private void VerifyCursorStateFromPointers(IEnumerable <IMixedRealityPointer> pointers, CursorStateEnum state)
 {
     Assert.NotZero(pointers.ToReadOnlyCollection().Count);
     foreach (var pointer in pointers)
     {
         VerifyCursorState(pointer.BaseCursor, state);
     }
 }
Example #21
0
 /// <summary>
 /// Change the cursor state to the new state.  Override in cursor implementations.
 /// </summary>
 /// <param name="state"></param>
 public virtual void OnCursorStateChange(CursorStateEnum state)
 {
     cursorState = state;
 }
Example #22
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="name">Name of the animation state for the cursor.</param>
 /// <param name="cursorState">The enum state for the cursor's animation.</param>
 /// <param name="parameter">The linked animation parameter to used for the cursor state.</param>
 public AnimatedCursorData(string name, CursorStateEnum cursorState, AnimatorParameter parameter)
 {
     this.name        = name;
     this.cursorState = cursorState;
     this.parameter   = parameter;
 }
Example #23
0
    // Update is called once per frame
    void Update()
    {
        NowCursorState = tmpCursor.GetComponent <AnimatedCursor>().tmpCursorState;

        PlaceBtnState  = PlaceButton.GetComponent <ButtonInteraction>().NowButtonState;
        DeleteBtnState = DeleteButton.GetComponent <ButtonInteraction>().NowButtonState;
        CancelBtnState = CancelButton.GetComponent <ButtonInteraction>().NowButtonState;


        lineRenderer = GetComponent <LineRenderer>();

        //Debug.Log("Cursor Position: " + tmpCursor.transform.position);

        //Vector3 CursorPosition = tmpCursor.GetComponent<Transform>().position;

        if ((ButtonInteraction.PosState == PosButtonType.PLACE) && (NowCursorState == CursorStateEnum.Release) &&
            (PlaceBtnState != ButtonStateEnum.Targeted) && (PlaceBtnState != ButtonStateEnum.Pressed) &&
            (DeleteBtnState != ButtonStateEnum.Observation) && (CancelBtnState != ButtonStateEnum.Observation))
        {
            if (SizeButtonCollection.SizeButtonState == SizeButtonType.MEDIUM)
            {
                offset = 6.0f;
            }
            else if (SizeButtonCollection.SizeButtonState == SizeButtonType.LARGE)
            {
                offset = 8.0f;
            }
            else if (SizeButtonCollection.SizeButtonState == SizeButtonType.SMALL)
            {
                offset = 5.0f;
            }

            Vector3 FinalPos = tmpCursor.transform.position - new Vector3(0f, 0f, 0.1f) * offset;
            Instantiate(PlaneObject, FinalPos, transform.rotation, this.transform);   //Genarate the drone

            ChildCount = this.transform.childCount;

            /*Use to process the three Red Light*/

            if (ChildCount > 1)
            {
                Vector3 pos1, pos2;                                                                          //the position of two way point(drone)
                Vector3 p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18; //Red light initial position
                pos1 = this.gameObject.transform.GetChild(ChildCount - 2).transform.position;
                pos2 = this.gameObject.transform.GetChild(ChildCount - 1).transform.position;

                p0  = (pos1 * 1 + pos2 * 19) / 20;
                p1  = (pos1 * 2 + pos2 * 18) / 20;
                p2  = (pos1 * 3 + pos2 * 17) / 20;
                p3  = (pos1 * 4 + pos2 * 16) / 20;
                p4  = (pos1 * 5 + pos2 * 15) / 20;
                p5  = (pos1 * 6 + pos2 * 14) / 20;
                p6  = (pos1 * 7 + pos2 * 13) / 20;
                p7  = (pos1 * 8 + pos2 * 12) / 20;
                p8  = (pos1 * 9 + pos2 * 11) / 20;
                p9  = (pos1 * 10 + pos2 * 10) / 20;
                p10 = (pos1 * 11 + pos2 * 9) / 20;
                p11 = (pos1 * 12 + pos2 * 8) / 20;
                p12 = (pos1 * 13 + pos2 * 7) / 20;
                p13 = (pos1 * 14 + pos2 * 6) / 20;
                p14 = (pos1 * 15 + pos2 * 5) / 20;

                p15 = (pos1 * 16 + pos2 * 4) / 20;
                p16 = (pos1 * 17 + pos2 * 3) / 20;
                p17 = (pos1 * 18 + pos2 * 2) / 20;
                p18 = (pos1 * 19 + pos2 * 1) / 20;


                L0 = Instantiate(CloneRedLight_0, p0, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L0.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L0.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L0.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L1 = Instantiate(CloneRedLight_1, p1, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L1.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L1.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L1.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L2 = Instantiate(CloneRedLight_2, p2, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L2.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L2.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L2.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L3 = Instantiate(CloneRedLight_3, p3, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L3.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L3.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L3.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L4 = Instantiate(CloneRedLight_4, p4, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L4.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L4.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L4.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L5 = Instantiate(CloneRedLight_5, p5, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L5.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L5.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L5.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L6 = Instantiate(CloneRedLight_6, p6, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L6.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L6.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L6.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L7 = Instantiate(CloneRedLight_7, p7, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L7.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L7.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L7.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L8 = Instantiate(CloneRedLight_8, p8, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L8.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L8.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L8.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L9 = Instantiate(CloneRedLight_9, p9, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L9.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L9.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L9.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L10 = Instantiate(CloneRedLight_10, p10, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L10.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L10.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L10.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L11 = Instantiate(CloneRedLight_11, p11, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L11.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L11.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L11.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L12 = Instantiate(CloneRedLight_12, p12, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L12.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L12.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L12.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L13 = Instantiate(CloneRedLight_13, p13, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L13.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L13.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L13.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L14 = Instantiate(CloneRedLight_14, p14, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L14.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L14.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L14.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;


                /////////////////////////////////////////
                L15 = Instantiate(CloneRedLight_15, p15, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L15.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L15.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L15.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L16 = Instantiate(CloneRedLight_16, p16, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L16.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L16.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L16.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L17 = Instantiate(CloneRedLight_17, p17, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L17.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L17.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L17.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;

                L18 = Instantiate(CloneRedLight_18, p18, this.gameObject.transform.GetChild(ChildCount - 2).transform.rotation, LightManager.transform);
                L18.GetComponent <RedLightPos>().Obj1        = this.gameObject.transform.GetChild(ChildCount - 2).gameObject;
                L18.GetComponent <RedLightPos>().Obj2        = this.gameObject.transform.GetChild(ChildCount - 1).gameObject;
                L18.GetComponent <RedLightPos>().Current_Num = ChildCount - 2;
            }

            //WayPoint.Add(tmp);
            //Debug.Log("InstantiateInstantiateInstantiateInstantiateInstantiateInstantiate");
        }


        /* Line Process*/
        ChildCount = this.transform.childCount;
        lineRenderer.SetVertexCount(ChildCount);


        if (ChildCount > 1)
        {
            for (int i = 0; i < ChildCount; i++)
            {
                tmp = this.gameObject.transform.GetChild(i).gameObject;
                lineRenderer.SetPosition(i, tmp.transform.position);
            }


            /*Obstacle Detect*/
            for (int i = 0; i < ChildCount - 1; i++)
            {
                Obj1 = this.gameObject.transform.GetChild(i).gameObject;
                Obj2 = this.gameObject.transform.GetChild(i + 1).gameObject;
                Ray        ray = new Ray(Obj1.transform.position, Obj2.transform.position - Obj1.transform.position);
                RaycastHit hit;

                //Debug.Log( i + " -> " + (i+1) + " distance : " + Vector3.Distance(Obj1.transform.position, Obj2.transform.position));
                float distance = Vector3.Distance(Obj1.transform.position, Obj2.transform.position) - 0.1f;

                Physics.Raycast(ray, out hit, distance, mask);

                //When collision is NOT NULL, there is obstacles
                if (hit.transform != null)
                {
                    lineRenderer.material = LineMat2; // if collision the line become red
                    //Debug.Log("BBBBBBBBB");

                    //LineCollision = false;   // Let Other Script Know Collision State
                    //LineCollisionNum = i + 1;

                    Debug.Log("Blocked by : " + hit.transform.name);
                }
                //If is NULL -> No Obstacles
                else if (hit.transform == null)
                {
                    lineRenderer.material = LineMat1;
                    //LineCollision = true;
                    //LineCollisionNum = -1;
                    //Debug.Log("NNNNNNNNN");
                }

                //Debug.Log("Line color : " + lineRenderer.material);
            }
        }

        //if(ChildCount == 2) lineRenderer.SetPosition(2, new Vector3(0,0,1));
    }