Exemplo n.º 1
0
 private void Awake()
 {
     m_scrollRect  = GetComponent <ScrollRect>();
     m_rtcListener = GetComponentInChildren <RectTransformChangeListener>();
     m_rtcListener.RectTransformChanged += OnViewportRectTransformChanged;
     HierarchyView.AddSelectionListener(OnSelectionChanged);
     m_Components             = GetComponentsInChildren <ComponentEditor>();
     AspectManager.OnChanged += index =>
     {
         OnSelectionChanged(null, new SelectionChangedArgs(new object[] { }, new object[] { }));
     };
 }
Exemplo n.º 2
0
        protected override void Awake()
        {
            base.Awake();

            m_gameState = Dependencies.GameState;
            m_minimap   = Dependencies.Minimap;
            m_input     = Dependencies.InputManager;
            m_voxelMap  = Dependencies.Map;
            m_scaler    = GetComponentInParent <CanvasScaler>();

            m_gameState.Menu        += OnMenu;
            m_gameState.ActionsMenu += OnActionsMenu;

            m_rtChangeListener = m_selectableMinimap.GetComponent <RectTransformChangeListener>();
            m_rtChangeListener.RectTransformChanged += OnMinimapRectTransformChanged;

            m_hudControlBehavior             = m_selectableMinimap.GetComponent <HUDControlBehavior>();
            m_hudControlBehavior.Selected   += OnMinimapSelected;
            m_hudControlBehavior.Deselected += OnMinimapDeselected;
        }
Exemplo n.º 3
0
        private void Awake()
        {
            m_camera = GetComponent <Camera>();
            if (!m_fullscreen)
            {
                m_camera.rect = new Rect(0, 0, 1, 1);
            }

            GameObject outputGo = new GameObject(m_camera.name + " Output");

            outputGo.SetActive(false);


            m_output = outputGo.AddComponent <RawImage>();
            m_output.raycastTarget = false;
            if (m_overlayMaterial != null)
            {
                m_output.material = m_overlayMaterial;
            }

            RectTransform rt = outputGo.GetComponent <RectTransform>();

            rt.SetParent(m_outputRoot, false);
            rt.anchorMin = new Vector2(0, 0);
            rt.anchorMax = new Vector2(1, 1);
            rt.offsetMin = Vector2.zero;
            rt.offsetMax = Vector2.zero;
            rt.pivot     = Vector2.zero;

            m_canvas       = m_outputRoot.GetComponentInParent <Canvas>();
            m_canvasScaler = m_outputRoot.GetComponentInParent <CanvasScaler>();

            ResizeRenderTexture();
            ResizeOutput();

            m_rectTransformChangeListener = outputGo.AddComponent <RectTransformChangeListener>();
            m_rectTransformChangeListener.RectTransformChanged += OnRectTransformChanged;

            outputGo.SetActive(true);
        }
        protected override void Awake()
        {
            base.Awake();
            if (!Application.isPlaying)
            {
                return;
            }

            if (m_textPanel == null)
            {
                m_textPanel = GetComponentInChildren <TimelineTextPanel>(true);
            }

            if (m_pointer == null)
            {
                m_pointer = GetComponentInChildren <TimelinePointer>(true);
            }

            m_scrollRect = GetComponentInChildren <ScrollRect>(true);
            m_scrollRect.scrollSensitivity = 0;
            m_scrollRect.onValueChanged.AddListener(OnInitScrollRectValueChanged);

            m_hScrollbarListener          = m_scrollRect.horizontalScrollbar.GetComponentInChildren <DragAndDropListener>(true);
            m_vScrollbarListener          = m_scrollRect.verticalScrollbar.GetComponentInChildren <DragAndDropListener>(true);
            m_hScrollbarListener.Drop    += OnHorizontalScrollbarDrop;
            m_hScrollbarListener.EndDrag += OnHorizontalScrollbarDrop;
            m_vScrollbarListener.Drop    += OnVerticalScrolbarDrop;
            m_vScrollbarListener.EndDrag += OnVerticalScrolbarDrop;

            if (FixedHeight > -1)
            {
                ScrollbarResizer[] resizers = m_scrollRect.verticalScrollbar.GetComponentsInChildren <ScrollbarResizer>(true);
                for (int i = 0; i < resizers.Length; ++i)
                {
                    resizers[i].gameObject.SetActive(false);
                }
            }

            m_rtListener = m_scrollRect.gameObject.AddComponent <RectTransformChangeListener>();
            m_rtListener.RectTransformChanged += OnRectTransformChanged;

            if (m_output == null)
            {
                m_output = m_scrollRect.content.GetComponentInChildren <RawImage>(true);
            }

            GameObject cameraGo = RenderCameraPrefab != null?Instantiate(RenderCameraPrefab) : new GameObject();

            cameraGo.name = "TimelineGraphicsCamera";
            cameraGo.SetActive(false);

#if USE_RTE
            IRTE editor = IOC.Resolve <IRTE>();
            cameraGo.transform.SetParent(editor.Root, false);
#endif
            m_camera = cameraGo.GetComponent <Camera>();
            if (m_camera == null)
            {
                m_camera = cameraGo.AddComponent <Camera>();
            }
            m_camera.enabled          = false;
            m_camera.orthographic     = true;
            m_camera.orthographicSize = 0.5f;
            m_camera.clearFlags       = CameraClearFlags.SolidColor;
            m_camera.backgroundColor  = m_backgroundColor;
            m_camera.cullingMask      = 0;

            m_rtCamera            = cameraGo.AddComponent <RenderTextureCamera>();
            m_rtCamera.Fullscreen = false;
            m_rtCamera.Output     = m_output;

            cameraGo.SetActive(true);
            m_rtCamera.enabled = false;

            if (m_timelineGridParams == null)
            {
                CreateDefaultTimelineGridParams();
                m_timelineGridParams.HorLines          = 1;
                m_timelineGridParams.HorLinesSecondary = 2;
            }

            m_timelineGrid = m_output.GetComponent <TimelineGrid>();
            if (m_timelineGrid == null)
            {
                m_timelineGrid = m_output.gameObject.AddComponent <TimelineGrid>();
            }
            m_timelineGrid.Init(m_camera);


            m_dopesheet = m_output.gameObject.GetComponent <Dopesheet>();
            if (m_dopesheet == null)
            {
                m_dopesheet = m_output.gameObject.AddComponent <Dopesheet>();
            }
            m_dopesheet.Init(m_camera);
            SetTimelineGridParameters();

            Clip = new Dopesheet.DsAnimationClip();

            m_pointer.SampleChanged += OnTimelineSampleChanged;
            m_pointer.PointerDown   += OnTimlineClick;
            m_pointer.BeginDrag     += OnTimelineBeginDrag;
            m_pointer.Drag          += OnTimelineDrag;
            m_pointer.Drop          += OnTimelineDrop;

            if (m_boxSelection == null)
            {
                m_boxSelection = GetComponentInChildren <TimelineBoxSelection>();
            }

            if (m_boxSelection != null)
            {
                m_boxSelection.BeginSelection += OnBeginBoxSelection;
                m_boxSelection.Selection      += OnBoxSelection;
            }

            RenderGraphics();
        }