Пример #1
0
        protected override void OnEnable()
        {
            if (null == topButton)
            {
                topButton    = panel.Find("TopButton").GetComponent <UIButton>();
                middleButton = panel.Find("MiddleButton").GetComponent <UIButton>();
                bottomButton = panel.Find("BottomButton").GetComponent <UIButton>();

                topButton.ImageColor    = GlobalState.Settings.sky.topColor;
                middleButton.ImageColor = GlobalState.Settings.sky.middleColor;
                bottomButton.ImageColor = GlobalState.Settings.sky.bottomColor;
            }

            GlobalState.colorChangedEvent.AddListener(OnColorPickerChanged);
            GlobalState.colorReleasedEvent.AddListener(OnColorPickerReleased);
            GlobalState.colorClickedEvent.AddListener(OnColorPickerPressed);
            GlobalState.Instance.skyChangedEvent.AddListener(OnSkyChanged);


            if (null == gradientList)
            {
                gradientList = panel.Find("ListPanel/List").GetComponent <UIDynamicList>();
                gradientList.ItemClickedEvent += OnListItemClicked;

                // Fill list from Settings
                RebuildGradientList();
                gradientList.CurrentIndex = -1;
            }

            OnSkyChanged(GlobalState.Instance.SkySettings);
        }
Пример #2
0
        private void Awake()
        {
            world      = Utils.FindWorld();
            palette    = transform.parent.Find("Pivot/PaletteController/PaletteHandle").gameObject;
            vehicleHUD = transform.parent.Find("Vehicle_HUD").gameObject;
            cameraRig  = transform.parent;

            Transform volumes = Utils.FindRootGameObject("Volumes").transform;

            sceneVolume = volumes.Find("VolumePostProcess").gameObject;
            lobbyVolume = volumes.Find("VolumeLobby").gameObject;

            backToSceneButton          = transform.Find("UI/Control Panel/Panel/BackToSceneButton").GetComponent <UIButton>();
            backToSceneButton.Disabled = true;

            projectButtons = transform.Find("UI/Control Panel/Panel/Project").gameObject;
            projectButtons.SetActive(false);
            launchProjectButton = projectButtons.transform.Find("LaunchProjectButton").GetComponent <UIButton>();

            projectList        = transform.Find("UI/Projects Panel/List").GetComponent <UIDynamicList>();
            firstPageButton    = transform.Find("UI/Control Panel/List Panel/FirstPageButton").GetComponent <UIButton>();
            lastPageButton     = transform.Find("UI/Control Panel/List Panel/LastPageButton").GetComponent <UIButton>();
            previousPageButton = transform.Find("UI/Control Panel/List Panel/PreviousPageButton").GetComponent <UIButton>();
            nextPageButton     = transform.Find("UI/Control Panel/List Panel/NextPageButton").GetComponent <UIButton>();
            itemPrefab         = Resources.Load <GameObject>("Prefabs/UI/ProjectItem");
        }
Пример #3
0
        void Start()
        {
            prefabList = panel.Find("Prefabs/List").GetComponent <UIDynamicList>();
            bankList   = panel.Find("BankPanel/List").GetComponent <UIDynamicList>();

            AssetBankUtils.LoadAssets();
            AssetBankUtils.PopulateUIList(bankList, OnUIObjectEnter, OnUIObjectExit);
        }
Пример #4
0
        void Start()
        {
            Init();

            uiList = panel.GetComponentInChildren <UIDynamicList>();
            uiList.focusItemOnAdd = false;

            filterLabel = panel.Find("ListPanel/FilterLabel").GetComponent <UILabel>();

            AssetBankUtils.LoadAssets();
            AssetBankUtils.PopulateUIList(uiList, OnUIObjectEnter, OnUIObjectExit);
        }
Пример #5
0
        public static void OnCreateFromHierarchy()
        {
            Transform parent = null;
            Transform T      = UnityEditor.Selection.activeTransform;

            if (T != null)
            {
                parent = T;
            }

            UIDynamicList.Create("List", parent, Vector3.zero, default_width, default_height, default_margin, default_item_width, default_item_height, default_item_depth);
        }
Пример #6
0
        private void OnSceneGUI()
        {
            bool hasUIElementParent = HasUIElemParent();

            UIDynamicList uiList = target as UIDynamicList;

            Transform T = uiList.transform;

            Vector3 posRight   = T.TransformPoint(new Vector3(+uiList.width, -uiList.height / 2.0f, 0));
            Vector3 posBottom  = T.TransformPoint(new Vector3(uiList.width / 2.0f, -uiList.height, 0));
            Vector3 posAnchor  = T.TransformPoint(uiList.Anchor);
            float   handleSize = .3f * HandleUtility.GetHandleSize(posAnchor);
            Vector3 snap       = Vector3.one * 0.01f;

            EditorGUI.BeginChangeCheck();

            Handles.color = Handles.xAxisColor;
            Vector3 newTargetPosition_right = Handles.FreeMoveHandle(posRight, Quaternion.identity, handleSize, snap, Handles.SphereHandleCap);

            Handles.color = Handles.yAxisColor;
            Vector3 newTargetPosition_bottom = Handles.FreeMoveHandle(posBottom, Quaternion.identity, handleSize, snap, Handles.SphereHandleCap);

            Handles.color = Handles.zAxisColor;
            Vector3 newTargetPosition_anchor = Handles.FreeMoveHandle(posAnchor, Quaternion.identity, handleSize, snap, Handles.SphereHandleCap);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Change Dimensions");

                Vector3 deltaRight  = newTargetPosition_right - posRight;
                Vector3 deltaBottom = newTargetPosition_bottom - posBottom;
                Vector3 deltaAnchor = newTargetPosition_anchor - posAnchor;

                if (Vector3.SqrMagnitude(deltaRight) > Mathf.Epsilon)
                {
                    uiList.Width += deltaRight.x;
                }
                else if (Vector3.SqrMagnitude(deltaBottom) > Mathf.Epsilon)
                {
                    uiList.Height += -deltaBottom.y;
                }
                else if (Vector3.SqrMagnitude(deltaAnchor) > Mathf.Epsilon)
                {
                    Vector3 localDeltaAnchor = T.InverseTransformVector(deltaAnchor);
                    uiList.RelativeLocation += new Vector3(localDeltaAnchor.x, localDeltaAnchor.y, 0.0f);
                }
            }
        }
Пример #7
0
        public static void Create(
            string listName,
            Transform parent,
            Vector3 relativeLocation,
            float width,
            float height,
            float margin,
            float item_width,
            float item_height,
            float item_depth)
        {
            GameObject go = new GameObject(listName);

            // Find the anchor of the parent if it is a UIElement
            Vector3 parentAnchor = Vector3.zero;

            if (parent)
            {
                UIElement elem = parent.gameObject.GetComponent <UIElement>();
                if (elem)
                {
                    parentAnchor = elem.Anchor;
                }
            }

            UIDynamicList uiDynamicList = go.AddComponent <UIDynamicList>(); // NOTE: also creates the MeshFilter, MeshRenderer and Collider components

            uiDynamicList.relativeLocation        = relativeLocation;
            uiDynamicList.transform.parent        = parent;
            uiDynamicList.transform.localPosition = parentAnchor + relativeLocation;
            uiDynamicList.transform.localRotation = Quaternion.identity;
            uiDynamicList.transform.localScale    = Vector3.one;
            uiDynamicList.width      = width;
            uiDynamicList.height     = height;
            uiDynamicList.margin     = margin;
            uiDynamicList.itemWidth  = item_width;
            uiDynamicList.itemHeight = item_height;

            UIUtils.SetRecursiveLayer(go, "CameraHidden");
        }
Пример #8
0
        void Start()
        {
            Init();

            uiList = panel.GetComponentInChildren <UIDynamicList>();
            uiList.focusItemOnAdd = false;

            filterLabel = panel.Find("ListPanel/FilterLabel").GetComponent <UILabel>();

            // Create our storage for loaded objects
            bank = new GameObject(ASSET_BANK_NAME);
            bank.SetActive(false);

            // Add our predifined objects
            AddBuiltinAssets();

            // Add user defined objects
            StartCoroutine(ScanDirectory(GlobalState.Settings.assetBankDirectory, () =>
            {
                SceneManager.ListImportableObjects();
            }));
        }
Пример #9
0
        static IEnumerator _PopulateUIList(UIDynamicList uiList, UnityAction <int> onEnter, UnityAction <int> onExit)
        {
            while (!assetsLoaded)
            {
                yield return(null);
            }

            foreach (AssetBankItemData data in items.Values)
            {
                // Create thumbnail
                GameObject thumbnail = CreateThumbnail(data);
                UIGrabber  uiGrabber = data.thumbnailType switch
                {
                    ThumbnailType.Object => UIGrabber.Create3DGrabber(thumbnail),
                    ThumbnailType.Image => UIGrabber.CreateImageGrabber(thumbnail),
                    ThumbnailType.LazyImage => UIGrabber.CreateLazyImageGrabber(thumbnail, data.thumbnailPath),
                    ThumbnailType.Text => UIGrabber.CreateTextGrabber(thumbnail),
                    _ => throw new NotImplementedException()
                };
                uiGrabber.uid = data.uid;
                uiGrabber.onEnterUI3DObject.AddListener(onEnter);
                uiGrabber.onExitUI3DObject.AddListener(onExit);

                // Create item
                GameObject root = new GameObject(data.assetName)
                {
                    layer = LayerMask.NameToLayer("CameraHidden")
                };
                AssetBankItem item = root.AddComponent <AssetBankItem>();
                item.thumbnail = thumbnail;
                item.thumbnail.transform.parent         = root.transform;
                item.thumbnail.transform.localPosition += new Vector3(0, 0, -0.001f);
                item.data = data;

                // Add it to the list
                uiList.AddItem(item.transform);
            }
        }
Пример #10
0
 private void OnWizardCreate()
 {
     UIDynamicList.Create(listName, parentPanel ? parentPanel.transform : null, Vector3.zero, width, height, margin, itemWidth, itemHeight, itemDepth);
 }
Пример #11
0
 public static void PopulateUIList(UIDynamicList uiList, UnityAction <int> onEnter, UnityAction <int> onExit)
 {
     GlobalState.Instance.StartCoroutine(_PopulateUIList(uiList, onEnter, onExit));
 }
Пример #12
0
        public void SetPanel(Transform subPanel, Transform grassListPanel)
        {
            Transform P = subPanel;

            #region UI Setup

            uiNewButton = P.Find("CreateNewButton").GetComponent <UIButton>();
            uiNewButton.onReleaseEvent.AddListener(() => OnGrassCreateNewPressed());

            uiPickButton = P.Find("PickExistingButton").GetComponent <UIButton>();
            uiPickButton.onReleaseEvent.AddListener(() => OnGrassPickExistingPressed());

            uiActiveButton = P.Find("ActivePaintButton").GetComponent <UIButton>();
            uiActiveButton.onReleaseEvent.AddListener(() => OnStopPaintPressed());

            uiAddButton = P.Find("ModeAddButton").GetComponent <UIButton>(); // <---- Add is default.
            uiAddButton.onReleaseEvent.AddListener(() => OnGrassAddPressed());
            uiAddButton.Checked = true;

            uiRemoveButton = P.Find("ModeRemoveButton").GetComponent <UIButton>();
            uiRemoveButton.onReleaseEvent.AddListener(() => OnGrassRemovePressed());

            uiEditButton = P.Find("ModeEditButton").GetComponent <UIButton>();
            uiEditButton.onReleaseEvent.AddListener(() => OnGrassEditPressed());

            uiPaintParamsButton = P.Find("PaintParametersPanelButton").GetComponent <UIButton>(); // <---- Paint is default.
            uiPaintParamsButton.onReleaseEvent.AddListener(() => OnPaintParamsPressed());
            uiPaintParamsButton.Checked = true;

            uiRenderParamsButton = P.Find("RenderParametersPanelButton").GetComponent <UIButton>();
            uiRenderParamsButton.onReleaseEvent.AddListener(() => OnRenderParamsPressed());

            uiPaintParamsPanel = P.Find("PaintParametersPanel").GetComponent <UIPanel>(); // <---- PaintParams is default.
            uiPaintParamsPanel.gameObject.SetActive(true);

            uiRenderParamsPanel = P.Find("RenderParametersPanel").GetComponent <UIPanel>();
            uiRenderParamsPanel.gameObject.SetActive(false);

            // PAINT PARAMS
            P = uiPaintParamsPanel.transform;

            uiBrushSizeSlider = P.Find("GrassBrushSize").GetComponent <UISlider>();
            uiBrushSizeSlider.onSlideEvent.AddListener((float value) => OnBrushSizeChanged(value));

            uiDensitySlider = P.Find("GrassDensity").GetComponent <UISlider>();
            uiDensitySlider.onSlideEventInt.AddListener((int value) => OnDensityChanged(value));

            uiWidthMultiplierSlider = P.Find("WidthMultiplier").GetComponent <UISlider>();
            uiWidthMultiplierSlider.onSlideEvent.AddListener((float value) => OnWidthMultiplierChanged(value));

            uiHeightMultiplierSlider = P.Find("HeightMultiplier").GetComponent <UISlider>();
            uiHeightMultiplierSlider.onSlideEvent.AddListener((float value) => OnHeightMultiplierChanged(value));

            uiHueShiftSlider = P.Find("HueShift").GetComponent <UISlider>();
            uiHueShiftSlider.onSlideEvent.AddListener((float value) => OnHueShiftChanged(value));

            uiSaturationShiftSlider = P.Find("SaturationShift").GetComponent <UISlider>();
            uiSaturationShiftSlider.onSlideEvent.AddListener((float value) => OnSaturationShiftChanged(value));

            uiValueShiftSlider = P.Find("ValueShift").GetComponent <UISlider>();
            uiValueShiftSlider.onSlideEvent.AddListener((float value) => OnValueShiftChanged(value));

            // RENDER PARAMS
            P = uiRenderParamsPanel.transform;

            uiGrassWidthSlider = P.Find("GrassWidth").GetComponent <UISlider>();
            uiGrassWidthSlider.onSlideEvent.AddListener((float value) => OnGrassWidthChanged(value));

            uiGrassHeightSlider = P.Find("GrassHeight").GetComponent <UISlider>();
            uiGrassHeightSlider.onSlideEvent.AddListener((float value) => OnGrassHeightChanged(value));

            uiGrassBendingSlider = P.Find("GrassBending").GetComponent <UISlider>();
            uiGrassBendingSlider.onSlideEvent.AddListener((float value) => OnGrassBendingChanged(value));

            uiTopColorButton = P.Find("TopColorButton").GetComponent <UIButton>();
            uiTopColorButton.onReleaseEvent.AddListener(() => OnTopColorPressed());

            uiBottomColorButton = P.Find("BottomColorButton").GetComponent <UIButton>();
            uiBottomColorButton.onReleaseEvent.AddListener(() => OnBottomColorPressed());

            // LIST
            grassList = grassListPanel.Find("List").GetComponent <UIDynamicList>();
            grassList.ItemClickedEvent += OnSelectGrassItem;

            #endregion
        }