コード例 #1
0
        protected void Update()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                // Not allowed in play mode
                CWiz.ShowNotification("Cannot use SRIA wizard during play mode", false, false);
                Close();
                return;
            }

            UpdateImplWithoutChecks();

            // Wait for scripts recompilation
            if (EditorApplication.isCompiling)
            {
                return;
            }

            // It's ok to delay the starting of updates until the gui resources are initialized, in order to have averything prepared
            if (_GUIResourcesInitialized)
            {
                UpdateImpl();
            }

            // SlowUpdate calling
            if (_CurrentFrameInSlowUpdateCycle % CWiz.SLOW_UPDATE_SKIPPED_FRAMES == 0)
            {
                _CurrentFrameInSlowUpdateCycle = 0;
                SlowUpdate();
            }
            else
            {
                ++_CurrentFrameInSlowUpdateCycle;
            }
        }
コード例 #2
0
        protected override void OnSubmitClicked()
        {
            // Commented: this is already checked and if there's and error, the submit button is disabled
            //string reasonIfNotValid;
            //// Validate again, to make sure the hierarchy wasn't modified
            //if (!Validate(out reasonIfNotValid))
            //{
            //	C.ShowCouldNotExecuteCommandNotification(this);
            //	Debug.Log("SRIA: Could not create ScrollView on the selected object: " + reasonIfNotValid);
            //	return;
            //}
            var        parentGO = Selection.gameObjects[0];
            GameObject go       = new GameObject("SRIA", typeof(RectTransform));
            var        image    = go.AddComponent <Image>();
            var        c        = Color.white;

            c.a         = .13f;
            image.color = c;
            var scrollRect   = go.AddComponent <ScrollRect>();
            var scrollRectRT = scrollRect.transform as RectTransform;
            var parentRT     = parentGO.transform as RectTransform;

            scrollRectRT.anchorMin = new Vector2(Mathf.Clamp01(CWiz.SPACE_FOR_SCROLLBAR / parentRT.rect.width), Mathf.Clamp01(CWiz.SPACE_FOR_SCROLLBAR / parentRT.rect.height));
            scrollRectRT.anchorMax = Vector2.one - scrollRectRT.anchorMin;
            scrollRectRT.sizeDelta = Vector2.zero;

            GameObjectUtility.SetParentAndAlign(go, parentGO);
            var viewportRT = CreateRTAndSetParent("Viewport", go.transform);

            viewportRT.gameObject.AddComponent <Image>();
            viewportRT.gameObject.AddComponent <Mask>().showMaskGraphic = false;
            var contentRT = CreateRTAndSetParent("Content", viewportRT);

            scrollRect.content = contentRT;
#if SCROLLRECT_HAS_VIEWPORT
            scrollRect.viewport = viewportRT;
#endif
            Canvas.ForceUpdateCanvases();

            // Register the creation in the undo system
            Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
            Selection.activeObject = go;

            ConfigureScrollView(scrollRect, viewportRT);
            Close();

            var validationResult = InitSRIAWindow.Validate(false, scrollRect);             // checkForWindows=false, becase this windows is already opened
            if (!validationResult.isValid)
            {
                CWiz.ShowCouldNotExecuteCommandNotification(this);
                Debug.LogError("SRIA: Unexpected internal error while trying to initialize. Details(next line):\n" + validationResult.reasonIfNotValid + "\n" + validationResult.ToString());
                return;
            }

            InitSRIAWindow.Open(new InitSRIAWindow.Parameters(validationResult));
        }
コード例 #3
0
        static void CreateSRIA(MenuCommand menuCommand)
        {
            string reasonIfNotValid;

            // Manually checking for validation, as this provides richer info about the case when creation is not possible
            if (!CreateSRIAWindow.Validate(true, out reasonIfNotValid))
            {
                CWiz.ShowCouldNotExecuteCommandNotification(null);
                Debug.Log("SRIA: Could not create ScrollView on the selected object: " + reasonIfNotValid);
                return;
            }

            CreateSRIAWindow.Open(new CreateSRIAWindow.Parameters());
        }
コード例 #4
0
        static void OptimizeSelectedScrollRectWithSRIA(MenuCommand command)
        {
            ScrollRect scrollRect       = (ScrollRect)command.context;
            var        validationResult = InitSRIAWindow.Validate(true, scrollRect);

            // Manually checking for validation, as this provides richer info about the case when initialization is not possible
            if (!validationResult.isValid)
            {
                CWiz.ShowCouldNotExecuteCommandNotification(null);
                Debug.Log("SRIA: Could not optimize '" + scrollRect.name + "': " + validationResult.reasonIfNotValid);
                return;
            }

            InitSRIAWindow.Open(new InitSRIAWindow.Parameters(validationResult));
        }