public void ShowSimtoms() { if (Data.Instance.UserSimtoms == null || Data.Instance.UserSimtoms.Count == 0) { foreach (var simComp in _simtomsPool) { simComp.GameObject.SetActive(false); } return; } foreach (Simtom simtom in Data.Instance.UserSimtoms) { var wasNull = UsefullUtils.CheckInPool( simtom.id, GameHiddenOptions.Instance.SimtomPrefab, SimtomsParent, out IPrefabComponent simtomComponent, ref _simtomsPool ); simtomComponent.Id = simtom.id; simtomComponent.GameObject.name = simtom.nume; (simtomComponent as SimtomComponent).Text.text = simtom.nume; //Sprite sprite = Resources.Load("ProductImages/" + product.PicturePath, typeof(Sprite)) as Sprite; //(simtomComponent as SimtomComponent).SetImage(sprite); if (wasNull) { _simtomsPool.Add(simtomComponent); } } }
private void InitList() { if (_itemsPool != null) { foreach (IPrefabComponent ipc in _itemsPool) { ipc.GameObject.SetActive(false); } } foreach (ItemOption item in Items) { var wasNull = UsefullUtils.CheckInPool( (component) => { return(component.Id == item.Value); }, ItemPrefab, transform, out IPrefabComponent el, ref _itemsPool ); el.GameObject.name = item.Value + "_" + item.Text; (el as InLineItemComponent).Init(item, OnSelectedItemCallback); if (wasNull) { _itemsPool.Add(el); } } }
public void OnMedicamentePropuse() { foreach (Medicament medicament in _medicamentePropuse) { var wasNull = UsefullUtils.CheckInPool( medicament.id, MedicamentPrefab, MedicamentParent.transform, out IPrefabComponent medicamentComponent, ref _medicamentsPool ); medicamentComponent.Id = medicament.id; medicamentComponent.GameObject.name = medicament.nume; (medicamentComponent as MedicamentComponent).Name.text = medicament.nume; Debug.Log(medicament.nume); Sprite sprite = Resources.Load("Images/" + medicament.pic, typeof(Sprite)) as Sprite; (medicamentComponent as MedicamentComponent).SetImage(sprite); if (wasNull) { _medicamentsPool.Add(medicamentComponent); } } var newHeight = (_medicamentePropuse.Count / 2) * 440; MedicamentParent.sizeDelta = new Vector2(MedicamentParent.sizeDelta.x, newHeight); }
public override void OnInspectorGUI() { ActManager myTarget = (ActManager)target; EditorGUILayout.BeginHorizontal(); Rect resetBut = new Rect( 0, 0, UsefullUtils.GetPercent(Screen.width, 25), 25 ); if (GUI.Button(resetBut, "Reset Start")) { myTarget.gameObject.GetComponent <ActController>().SetStartAtAct(""); } Rect resetSBut = new Rect( UsefullUtils.GetPercent(Screen.width, 25) + 15, 0, UsefullUtils.GetPercent(Screen.width, 25), 25 ); if (GUI.Button(resetSBut, "Reset Speed")) { myTarget.gameObject.GetComponent <ActController>().SetStartAtAct(""); } // GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); // Show default inspector property editor DrawDefaultInspector(); }
public void CreateDangerousEngine() { DangerousEngineCreated = true; //var trainingFilePath = string.Format(@"Assets/StreamingAssets/{0}", Data.Instance.TraingDangerousDataPath); //var testingFilePath = string.Format(@"Assets/StreamingAssets/{0}", Data.Instance.TestDangerousDataPath); var trainingFilePath = UsefullUtils.GetPathToStreamingAssetsFile(Data.Instance.TraingDangerousDataPath); var testingFilePath = UsefullUtils.GetPathToStreamingAssetsFile(Data.Instance.TestDangerousDataPath); var trainingData = GetDataFromCsv(trainingFilePath); var testData = GetDataFromCsv(testingFilePath); IDataView dataView = mlContext.Data.LoadFromEnumerable(trainingData); IDataView testDataView = mlContext.Data.LoadFromEnumerable(testData); // Step 4 - we need to create the pipeline and define the workflows in it // switch params: ("FeedBackText", "Features") to => ("Features", "FeedbackText") var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "Features") .Append(mlContext.BinaryClassification.Trainers .FastTree(numberOfLeaves: 50, numberOfTrees: 50, minimumExampleCountPerLeaf: 1)); // Step 5 - traing the algorithm and get the model out var model = pipeline.Fit(dataView); var predictions = model.Transform(testDataView); var metrics = mlContext.BinaryClassification.Evaluate(predictions, "Label"); // Step 7 - Use model _dangerousPredictionsEngine = mlContext.Model.CreatePredictionEngine <FeedBackTrainingData, FeedBackPrediction> (model); }
private void PlayShot() { _shotIndex++; if (_shotIndex >= ReplayOptions.Count) { return; } if (_playId.HasValue) { LeanTween.cancel(_playId.Value); _playId = null; } if (_playRotId.HasValue) { LeanTween.cancel(_playRotId.Value); _playRotId = null; } float time = UsefullUtils.GetPercent(ReplayOptions[_shotIndex].Seconds, PercentOffset); time += UsefullUtils.GetPercent(time, ReplaySpeed); _playId = LeanTween.move(Game.Instance.ReplayBall, ReplayOptions[_shotIndex].BallPos, time).id; LeanTween.descr(_playId.Value).setEase(LeanTweenType.linear); _playRotId = LeanTween.rotate(Game.Instance.ReplayBall, ReplayOptions[_shotIndex].BallRot, time).id; LeanTween.descr(_playRotId.Value).setEase(LeanTweenType.linear); LeanTween.descr(_playId.Value) .setOnComplete(() => { PlayShot(); }); }
public void Curve() { _isCurving = true; _maxLeftAmmount = UsefullUtils.GetPercent(Mathf.Abs(_rb.velocity.x), MaxLeftPerc); _curveId = LeanTween.value(LeftAmmount, _maxLeftAmmount, TimeInMagnus).id; LeanTween.descr(_curveId.Value) .setOnUpdate(ChangeLeftAmmount); LeanTween.descr(_curveId.Value).setEase(LeanTweenType.easeInOutBack); LeanTween.descr(_curveId.Value) .setOnComplete(() => { _curveId = null; _isTorqueing = true; _curveId = LeanTween.value(LeftAmmount, _minLeftAmmount, TimeOutMagnus).id; LeanTween.descr(_curveId.Value) .setOnUpdate(ChangeLeftAmmount); LeanTween.descr(_curveId.Value) .setOnComplete(() => { _curveId = null; _isCurving = false; _isTorqueing = false; }); }); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // base.OnGUI(position, property, label); EditorGUI.BeginProperty(position, label, property); EditorGUI.BeginChangeCheck(); Rect foldPos = new Rect(position.x + 0, position.y + 0, position.width, 15); Rect startHLabelPos = new Rect( position.x + UsefullUtils.GetPercent(position.width, 0), position.y + 15, UsefullUtils.GetPercent(position.width, 25), 25 ); Rect speedPos = new Rect( position.x + UsefullUtils.GetPercent(position.width, 30), position.y + 15, UsefullUtils.GetPercent(position.width, 25), 25 ); Rect goPos = new Rect( position.x + UsefullUtils.GetPercent(position.width, 60), position.y + 15, UsefullUtils.GetPercent(position.width, 40), 25 ); SerializedProperty p = property.FindPropertyRelative("_editor_foldout"); if (p.boolValue = EditorGUI.Foldout(foldPos, p.boolValue, property.displayName)) { GUI.Label(foldPos, property.displayName); if (GUI.Button(startHLabelPos, "Start Here")) { (property.serializedObject.targetObject as ActManager).GetComponent <ActController>() .SetStartAtAct(property.propertyPath); } GameObject value = (GameObject)EditorGUI.ObjectField( goPos, "", (property.FindPropertyRelative("Go").objectReferenceValue as GameObject), typeof(GameObject), true ); property.FindPropertyRelative("_choiceIndex").intValue = EditorGUI.Popup(speedPos, property.FindPropertyRelative("_choiceIndex").intValue, _speeds); // var someClass = target as SomeClass; // Update the selected choice in the underlying object // someClass.choice = _choices[_choiceIndex]; // Save the changes back to the object // EditorUtility.SetDirty(target); if (EditorGUI.EndChangeCheck()) { property.FindPropertyRelative("Go").objectReferenceValue = value; property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); } } EditorGUI.EndProperty(); }
public void ReadString() { string path = UsefullUtils.GetPathToStreamingAssetsFile("Settings.txt"); //Read the text from directly from the test.txt file StreamReader reader = new StreamReader(path); IS_LOGGED_IN = reader.ReadToEnd() == "LOGGED_IN"; reader.Close(); }
private void ToForthFold() { topY += 25; Rect secondToggled = new Rect(topX, topY, insideFoldWidth, 100); GUILayout.BeginArea(secondToggled); myTarget.UseForth = GUILayout.Toggle(myTarget.UseForth, "Forth", "Button", GUILayout.Width(UsefullUtils.GetPercent(Screen.width, 10)), GUILayout.Height(height)); GUILayout.EndArea(); }
public void UpdateCategoriesQuestions() { var savedCategories = DataService.GetAllCategories(); foreach (var category in savedCategories) { var filePath = UsefullUtils.GetPathToStreamingAssetsFile(category.File + ".html"); category.MaxLines = UsefullUtils.CountLinesInFile(filePath); } DataService.WriteCategoriesData(savedCategories, update: true); }
private void RegisterPoint(Block block) { if (block == null) { Debug.Break(); } int scoreToAdd = block.Points; if (_previousBlockTypeHit == BlockType.Proppeler) { // bonus if you hit the first time: 100% scoreToAdd = (scoreToAdd * 2); // bonus points based on distance from proppeler to sphere // the bigger the better var distance = Vector3.Distance(_previousHitPoint, _currentHitPoint); var percentToHit = UsefullUtils.GetValuePercent(distance, _maxPossibleDistance); float bonusDistancePoints; if (percentToHit > 40) // bigger value decreases points { // bonus points based on distance from a contact point to proppeler // the smaller the better distance = Vector3.Distance(_pastPreviousHitPoint, _previousHitPoint); var percentToProppeler = UsefullUtils.GetValuePercent(distance, _maxPossibleDistance); percentToProppeler = percentToHit - percentToProppeler; bonusDistancePoints = UsefullUtils.GetPercent(scoreToAdd, percentToProppeler); scoreToAdd += (int)Mathf.Ceil(bonusDistancePoints); } bonusDistancePoints = UsefullUtils.GetPercent(scoreToAdd, percentToHit); scoreToAdd += (int)Mathf.Ceil(bonusDistancePoints); // score is a bit high, so lets trim it down a bit. // // WE CAN REMOVE THIS LATER // //var percentToDecrease = scoreToAdd = (int)Mathf.Ceil(UsefullUtils.GetPercent(scoreToAdd, 60)); Score += scoreToAdd; } else { Score += scoreToAdd; } ScoreText.text = Score.ToString(); Game.Instance.CanvasController.ShowcasePoints(scoreToAdd, _currentHitPoint); }
private IPrefabComponent AddElementInPool(Element element, bool isInitializingElements = false) { var prefab = GameHiddenOptions.Instance.GetPrefabElement(element.ElementType); var wasNull = UsefullUtils.CheckInPool( (IPrefabComponent component) => { var typeId = (ElementType)((component as IElementComponent).TypeId); if (component.GameObject.activeSelf == false && typeId == element.ElementType) { return(true); } return(false); }, prefab, transform, out IPrefabComponent el, ref _elementsPool ); el.UniqueId = element.UniqueId(); el.GameObject.name = ElementsService.GetElementName(element); if (element.ElementType != ElementType.Picture) { var elementComponent = (el as ITextComponent); elementComponent.SetText(element.Text); } else { if (element.Paths != null) { (el as IPictureComponent).Paths = element.Paths; (el as IPictureComponent).FillImages(); } } (el as IElementComponent).TypeId = element.TypeId; if (wasNull) { if (isInitializingElements) { _elementsPool.Add(el); } else { _elementsPool.Insert(element.Index, el); } } return(el); }
public void onCartProductsLoaded(List <CartProduct> cartProducts) { _cartProducts = cartProducts; if (_cartProductsPool != null) { foreach (var item in _cartProductsPool) { item.GameObject.SetActive(false); } } float totalPrice = 0; foreach (CartProduct cartProduct in _cartProducts) { var wasNull = UsefullUtils.CheckInPool( cartProduct.id_product_options, GameHiddenOptions.Instance.CartProductPrefab, CartProductsParent.transform, out IPrefabComponent cartProductComponent, ref _cartProductsPool ); cartProductComponent.Id = cartProduct.id_product_options; cartProductComponent.Route = new Route(); cartProductComponent.GameObject.name = cartProduct.product_name; (cartProductComponent as CartProductComponent).Name.text = cartProduct.product_name; (cartProductComponent as CartProductComponent).Description.text = GetComandaDescription(cartProduct); (cartProductComponent as CartProductComponent).Quantity.text = cartProduct.quantity.ToString(); (cartProductComponent as CartProductComponent).PriceTotal.text = cartProduct.total_price.ToString() + " Lei"; totalPrice += cartProduct.total_price; (cartProductComponent as CartProductComponent).OnChangeQuantity = OnChangeQuantity; Sprite sprite = Resources.Load("ProductImages/" + cartProduct.picture_path, typeof(Sprite)) as Sprite; (cartProductComponent as CartProductComponent).SetImage(sprite); if (wasNull) { _cartProductsPool.Add(cartProductComponent); } } var newHeight = (_cartProducts.Count) * 100; CartProductsParent.sizeDelta = new Vector2(CartProductsParent.sizeDelta.x, newHeight); TotalPrice.text = totalPrice.ToString(); }
// Start is called before the first frame update void Awake() { if (GameObject.Find("_GameHiddenOptions (DD)") == null) { foreach (var prefab in DontDestroyPrefabs) { UsefullUtils.CreateGameObject(Instantiate(prefab), prefab.name); } } GameService.Instance.InternalWait(() => { StarterGameObject.GetComponent <ISceneStarter>().InitScene(); }, 0.1f); }
private void OnProductsLoaded(List <Product> products) { _products = products; if (_productsPool != null) { foreach (var item in _productsPool) { item.GameObject.SetActive(false); } } foreach (Product product in _products) { var wasNull = UsefullUtils.CheckInPool( product.id, GameHiddenOptions.Instance.ProductPrefab, ProductsParent.transform, out IPrefabComponent productComponent, ref _productsPool ); productComponent.Id = product.id; productComponent.Route = new Route() { RoutePath = "Product", RouteKey = product.id }; productComponent.GameObject.name = product.name; (productComponent as ProductComponent).Name.text = product.name; (productComponent as ProductComponent).PriceOld.text = product.product_price.ToString() + " Lei"; var randomNr = ((int)Random.Range(1, 4)) * 10; var oldPrice = UsefullUtils.GetPercent(product.product_price, 100 - randomNr); (productComponent as ProductComponent).ReducePercent.text = "- " + randomNr.ToString() + " %"; (productComponent as ProductComponent).Price.text = oldPrice + " Lei"; Sprite sprite = Resources.Load("ProductImages/" + product.picture_path, typeof(Sprite)) as Sprite; (productComponent as ProductComponent).SetImage(sprite); if (wasNull) { _productsPool.Add(productComponent); } } var newHeight = (_products.Count / 2) * 240; ProductsParent.sizeDelta = new Vector2(ProductsParent.sizeDelta.x, newHeight); }
public void StopRecording() { _fullElapsedTime = DateTime.Now - _fullStartTime; float fullTime = 0; ReplayOptions.ForEach(rp => fullTime += rp.Seconds); PercentOffset = Mathf.Floor(UsefullUtils.GetValuePercent(_fullElapsedTime.Seconds, fullTime)); _startRecord = false; Game.Instance.Ball.CanStopRecording = false; PlayRecordButton.interactable = true; }
public (IDataView training, IDataView test) LoadData(MLContext mlContext) { var trainingPath = Data.Instance.TraingDataPath; var testingPath = Data.Instance.TraingDataPath; //var trainingDataPath = string.Format(@"Assets/StreamingAssets/{0}", trainingPath); //var testDataPath = string.Format(@"Assets/StreamingAssets/{0}", testingPath); var trainingDataPath = UsefullUtils.GetPathToStreamingAssetsFile(trainingPath); var testDataPath = UsefullUtils.GetPathToStreamingAssetsFile(testingPath); IDataView trainingDataView = mlContext.Data.LoadFromTextFile <MedicRating>(trainingDataPath, hasHeader: true, separatorChar: ','); IDataView testDataView = mlContext.Data.LoadFromTextFile <MedicRating>(testDataPath, hasHeader: true, separatorChar: ','); return(trainingDataView, testDataView); }
private void OnCategoriesLoaded(List <Category> categories) { Categories = categories; if (_categoriesPool != null) { foreach (CategoryComponent cc in _categoriesPool) { cc.gameObject.SetActive(false); } } foreach (Category category in Categories) { var wasNull = UsefullUtils.CheckInPool( category.id, GameHiddenOptions.Instance.CategoryPrefab, this.transform, out IPrefabComponent categoryComponent, ref _categoriesPool ); categoryComponent.Id = category.id; categoryComponent.Route = new Route() { RoutePath = _actionRoutePath, RouteKey = category.id, ExtraRouteKeys = (_actionRoutePath == "Products" ? new Dictionary <string, int>() { { "categoryId", _categoryId } } : null) }; (categoryComponent as CategoryComponent).CategoryName.text = category.description; if (wasNull) { _categoriesPool.Add(categoryComponent); } } }
void Start() { _stories = StoryService.Instance.GetStories(); if (_stories == null || _stories.Count == 0) { ShowNewStoryFields(); ProjectHotkeyEditor.Instance.ShowNewStoryMenu(); return; } UsefullUtils.DumpToJsonConsole(_stories.Cast <IJsonConsole>().ToArray()); foreach (Story story in _stories) { var prefab = GameHiddenOptions.Instance.StoryComponentPrefab; var wasNull = UsefullUtils.CheckInPool( (IPrefabComponent component) => { return(false); }, prefab, OpenStoryPanel.transform, out IPrefabComponent s, ref _storiesPool ); s.UniqueId = s.Id = story.Id; (s as StoryComponent).StoryId.text = story.Id.ToString(); (s as StoryComponent).StoryName.text = story.Name; (s as StoryComponent).StoryPath.text = story.Path; if (wasNull) { _storiesPool.Add(s); } } SelectStory(ArrowDirection.Down, 0); }
public void KeepElementInView(RectTransform toGameObject) { Assets.Scripts.Utils.UIX.UpdateLayout(ScrollRect.transform); // Debug.Log("----------------------------------------------------------------------"); var byWhatPercent = 0f; var topSpace = 250f; var percent = GetCarretPositionPercent(Mathf.Abs(toGameObject.anchoredPosition.y) + topSpace); // Debug.Log("percent: " + percent); if (percent > 50) { // Debug.Log("Lower part of the document"); byWhatPercent = Mathf.Abs(100 - (percent - 50)); // Debug.Log(percent + ", " + byWhatPercent); topSpace = UsefullUtils.GetPercent(550, byWhatPercent); // Debug.Log(topSpace); percent = GetCarretPositionPercent(Mathf.Abs(toGameObject.anchoredPosition.y) + topSpace); } else { byWhatPercent = Mathf.Abs(100 - (50 - percent)); // Debug.Log(percent + ", " + byWhatPercent); topSpace = UsefullUtils.GetPercent(250f, byWhatPercent); // Debug.Log(topSpace); percent = GetCarretPositionPercent(Mathf.Abs(toGameObject.anchoredPosition.y) + topSpace); // Debug.Log("Upper part of the document"); } // Debug.Log("percent: " + percent); var scrollValue = UsefullUtils.InvertPercent(percent) / 100; // Debug.Log("scrollValue: " + scrollValue); Scroll(scrollValue); }
void StartStory() { Acts = new List <IAct>(); if (string.IsNullOrWhiteSpace(StartAtAct)) { StartAtAct = ActManager.Instance().GetActDict().ElementAt(0).Key; ActIndex = 0; } else { if (UsefullUtils.IsDigitsOnly(StartAtAct)) { ActIndex = System.Convert.ToInt32(StartAtAct); StartAtAct = ActManager.Instance().GetActDict().ElementAt(ActIndex).Key; } else { ActIndex = System.Array.IndexOf(ActManager.Instance().GetActDict().Keys.ToArray(), StartAtAct); } } Debug.Log(ActIndex); StartAct(); }
private float GetCarretPositionPercent(float heightOfCarretFromTopOfPage) { // Debug.Log("heightOfCarretFromTopOfPage: " + heightOfCarretFromTopOfPage); // Debug.Log("Content.sizeDelta.y: " + Content.sizeDelta.y); return(UsefullUtils.GetValuePercent(heightOfCarretFromTopOfPage, Content.sizeDelta.y)); }
public void ApplyStyle(bool atRunTime = false) { RectTransform thisRect = gameObject.GetComponent <RectTransform>(); RectTransform thisParentRect; if (UseCustomParent) { if (ParentRect == null) { thisParentRect = gameObject.transform.parent.GetComponent <RectTransform>(); UseCustomParent = false; } else { thisParentRect = ParentRect; } } else { thisParentRect = gameObject.transform.parent.GetComponent <RectTransform>(); ParentRect = null; } var newWidth = thisRect.sizeDelta.x; var newHeight = thisRect.sizeDelta.y; if (ApplyWidth) { switch (WidthSizeUnit) { case SizeUnit.Pixels: newWidth = Width; break; case SizeUnit.Percent: newWidth = UsefullUtils.GetPercent(thisParentRect.sizeDelta.x, Width); break; default: float screenSizeWidth = (float)Screen.width; if (atRunTime == false) { screenSizeWidth = ((CompileStyles)FindObjectOfType(typeof(CompileStyles))).ReferenceResolution.x; } newWidth = UsefullUtils.GetPercent(screenSizeWidth, Width); break; } } if (ApplyHeight) { switch (HeightSizeUnit) { case SizeUnit.Pixels: newHeight = Height; break; case SizeUnit.Percent: newHeight = UsefullUtils.GetPercent(thisParentRect.sizeDelta.y, Height); break; default: float screenSizeHeight = (float)Screen.height; if (atRunTime == false) { screenSizeHeight = ((CompileStyles)FindObjectOfType(typeof(CompileStyles))).ReferenceResolution.y; } newHeight = UsefullUtils.GetPercent(screenSizeHeight, Height); break; } } thisRect.sizeDelta = new Vector2(newWidth, newHeight); }
public void WriteString(string setting) { string path = UsefullUtils.GetPathToStreamingAssetsFile("Settings.txt"); File.WriteAllText(path, setting); }
public override void OnInspectorGUI() { if (ToggleButtonStyleNormal == null) { ToggleButtonStyleNormal = "Button"; ToggleButtonStyleToggled = new GUIStyle(ToggleButtonStyleNormal); ToggleButtonStyleToggled.normal.background = ToggleButtonStyleToggled.active.background; } myTarget = (TransformChanges)target; var minHeight = 30; if (myTarget.OriginalFoldout) { minHeight = 150; } if (myTarget.ToSecondFoldout) { minHeight = 200; } var componentHeight = ((topY + 30) < minHeight) ? minHeight : (topY + 30); EditorGUILayout.BeginHorizontal(GUILayout.Width(Screen.width), GUILayout.Height(componentHeight)); EditorGUILayout.Space(5); topY = 5; topX = 20; Rect buttonPos = new Rect(topX - 10, topY, Screen.width, 100); GUILayout.BeginArea(buttonPos); EditorGUILayout.BeginHorizontal(); myTarget.TransformAnchorPos = GUILayout.Toggle(myTarget.TransformAnchorPos, "Anchor Pos", "Button", GUILayout.Width(UsefullUtils.GetPercent(Screen.width, 20)), GUILayout.Height(height)); myTarget.TransformDelta = GUILayout.Toggle(myTarget.TransformDelta, "Delta", "Button", GUILayout.Width(UsefullUtils.GetPercent(Screen.width, 20)), GUILayout.Height(height)); myTarget.TransformRotation = GUILayout.Toggle(myTarget.TransformRotation, "Rotation", "Button", GUILayout.Width(UsefullUtils.GetPercent(Screen.width, 20)), GUILayout.Height(height)); EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); // insideFoldWidth = Screen.width - 40; if (myTarget.TransformAnchorPos || myTarget.TransformDelta || myTarget.TransformRotation) { OriginalFold(); ToSecondFold(); topY += 25; Rect foldPos = new Rect(topX - 5, topY, Screen.width, 15); if (myTarget.MoreThenOne = EditorGUI.Foldout(foldPos, myTarget.MoreThenOne, "More")) { insideFoldSecondLevelWidth = Screen.width - 60; topXSecondLevel = topX + 20; ToThirdFold(); ToForthFold(); } } else { topY += 25; Rect textPos = new Rect(topX - 5, topY, Screen.width, 30); GUILayout.BeginArea(textPos); EditorGUILayout.LabelField("Nothing to change so you should remove it!"); GUILayout.EndArea(); } EditorGUILayout.Space(10); EditorGUILayout.EndVertical(); EditorUtility.SetDirty(myTarget); EditorSceneManager.MarkSceneDirty(myTarget.gameObject.scene); }
public override void OnInspectorGUI() { DrawDefaultInspector(); EditorGUILayout.BeginVertical("box"); GUILayout.Space(5); GUILayout.Label("Database"); GUILayout.Space(5); if (GUILayout.Button("Recreate User Table")) { _action = InspectorButton.RecreateUserTable; } if (GUILayout.Button("Recreate Story Table")) { _action = InspectorButton.RecreateStoryTable; } if (GUILayout.Button("Recreate Page Table")) { _action = InspectorButton.RecreatePageTable; } if (GUILayout.Button("Recreate Element Table")) { _action = InspectorButton.RecreateElementTable; } GUILayout.Space(5); GUILayout.Label("Write Data"); GUILayout.Space(5); //if (GUILayout.Button("Write Categories Data")) // _action = InspectorButton.WriteCategoriesData; //if (GUILayout.Button("Update Categories Questions")) // _action = InspectorButton.UpdateCategoriesQuestions; GUILayout.Space(5); //if (GUILayout.Button("Write Default Data")) // _action = InspectorButton.WriteDefaultData; GUILayout.Space(5); EditorGUILayout.EndVertical(); //-------------------------------------------------------------------------------------------------------------------------------------------------------- GUILayout.Space(20); // CONFIRM //-------------------------------------------------------------------------------------------------------------------------------------------------------- if (_setupConfirm) { EditorGUILayout.BeginVertical("box"); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Confirm", GUILayout.Width(UsefullUtils.GetPercent(Screen.width, 25)), GUILayout.Height(50))) { ConfirmAccepted(); } if (GUILayout.Button("Cancel", GUILayout.Width(UsefullUtils.GetPercent(Screen.width, 25)), GUILayout.Height(50))) { _setupConfirm = false; } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUILayout.EndVertical(); } }
private void ToThirdFold() { topY += 25; Rect secondToggled = new Rect(topX, topY, insideFoldWidth, 100); GUILayout.BeginArea(secondToggled); myTarget.UseThird = GUILayout.Toggle(myTarget.UseThird, "Third", "Button", GUILayout.Width(UsefullUtils.GetPercent(Screen.width, 10)), GUILayout.Height(height)); GUILayout.EndArea(); if (myTarget.UseThird) { topY += 25; Rect foldPos = new Rect(topXSecondLevel - 5, topY, Screen.width, 15); if (myTarget.ToThirdFoldout = EditorGUI.Foldout(foldPos, myTarget.ToThirdFoldout, "To Third")) { topY += height; Rect buttonLock = new Rect(topXSecondLevel, topY, UsefullUtils.GetPercent(insideFoldSecondLevelWidth, 10), height); Rect buttonSet = new Rect(topXSecondLevel + UsefullUtils.GetPercent(insideFoldSecondLevelWidth, 10), topY, UsefullUtils.GetPercent(insideFoldSecondLevelWidth, 40), height); Rect buttonView = new Rect(topXSecondLevel + UsefullUtils.GetPercent(insideFoldSecondLevelWidth, 50), topY, UsefullUtils.GetPercent(insideFoldSecondLevelWidth, 50), height); if (GUI.Button(buttonLock, myTarget.ThirdLocked ? "Unlock" : "Lock")) { myTarget.ThirdLocked = !myTarget.ThirdLocked; } EditorGUI.BeginDisabledGroup(myTarget.ThirdLocked); if (GUI.Button(buttonSet, "Set Current" + (myTarget.ThirdLocked ? " (L)" : ""))) { if (myTarget.ThirdLocked) { return; } myTarget.SetCurrentThird(); } EditorGUI.EndDisabledGroup(); if (GUI.Button(buttonView, "View Now")) { myTarget.ViewNowThird(); } EditorGUI.BeginDisabledGroup(myTarget.ThirdLocked); if (myTarget.TransformAnchorPos) { topY += height; Rect origPos = new Rect(topXSecondLevel, topY, Screen.width, height); GUILayout.BeginArea(origPos); myTarget.ThirdAnchorPos = EditorGUILayout.Vector3Field("Anchor Pos", myTarget.ThirdAnchorPos, GUILayout.Height(height), GUILayout.Width(insideFoldSecondLevelWidth)); GUILayout.EndArea(); } if (myTarget.TransformDelta) { topY += height; Rect origDelta = new Rect(topXSecondLevel, topY, Screen.width, height); GUILayout.BeginArea(origDelta); myTarget.ThirdScaleDelta = EditorGUILayout.Vector2Field("Delta", myTarget.ThirdScaleDelta, GUILayout.Height(height), GUILayout.Width(insideFoldSecondLevelWidth)); GUILayout.EndArea(); } if (myTarget.TransformRotation) { topY += height; Rect origRot = new Rect(topXSecondLevel, topY, Screen.width, height); GUILayout.BeginArea(origRot); myTarget.ThirdRotation = EditorGUILayout.Vector3Field("Rotation", myTarget.ThirdRotation, GUILayout.Height(height), GUILayout.Width(insideFoldSecondLevelWidth)); GUILayout.EndArea(); } EditorGUI.EndDisabledGroup(); } } }
private void OriginalFold() { topY += 25; Rect foldPos = new Rect(topX - 5, topY, Screen.width, 15); if (myTarget.OriginalFoldout = EditorGUI.Foldout(foldPos, myTarget.OriginalFoldout, "Original")) { topY += height; Rect buttonLock = new Rect(topX, topY, UsefullUtils.GetPercent(insideFoldWidth, 10), height); Rect buttonSet = new Rect(topX + UsefullUtils.GetPercent(insideFoldWidth, 10), topY, UsefullUtils.GetPercent(insideFoldWidth, 40), height); Rect buttonView = new Rect(topX + UsefullUtils.GetPercent(insideFoldWidth, 50), topY, UsefullUtils.GetPercent(insideFoldWidth, 50), height); if (GUI.Button(buttonLock, myTarget.OriginalLocked ? "Unlock" : "Lock")) { myTarget.OriginalLocked = !myTarget.OriginalLocked; } EditorGUI.BeginDisabledGroup(myTarget.OriginalLocked); if (GUI.Button(buttonSet, "Set Current" + (myTarget.OriginalLocked ? " (L)" : ""))) { if (myTarget.OriginalLocked) { return; } myTarget.SetCurrent(); } EditorGUI.EndDisabledGroup(); if (GUI.Button(buttonView, "View Now")) { myTarget.ViewNow(); } EditorGUI.BeginDisabledGroup(myTarget.OriginalLocked); if (myTarget.TransformAnchorPos) { topY += height; Rect origPos = new Rect(topX, topY, Screen.width, height); GUILayout.BeginArea(origPos); myTarget.OriginalAnchorPos = EditorGUILayout.Vector3Field("Anchor Pos", myTarget.OriginalAnchorPos, GUILayout.Height(height), GUILayout.Width(insideFoldWidth)); GUILayout.EndArea(); } if (myTarget.TransformDelta) { topY += height; Rect origDelta = new Rect(topX, topY, Screen.width, height); GUILayout.BeginArea(origDelta); myTarget.OriginalScaleDelta = EditorGUILayout.Vector2Field("Original Delta", myTarget.OriginalScaleDelta, GUILayout.Height(height), GUILayout.Width(insideFoldWidth)); GUILayout.EndArea(); } if (myTarget.TransformRotation) { topY += height; Rect origRot = new Rect(topX, topY, Screen.width, height); GUILayout.BeginArea(origRot); myTarget.OriginalRotation = EditorGUILayout.Vector3Field("Original Rotation", myTarget.OriginalRotation, GUILayout.Height(height), GUILayout.Width(insideFoldWidth)); GUILayout.EndArea(); } EditorGUI.EndDisabledGroup(); } }
private CategoryComponent CreateCategoryComponent(Category category) { var go = UsefullUtils.CreateUiObject(Instantiate(GameHiddenOptions.Instance.CategoryPrefab), category.description, this.transform); return(go.GetComponent <CategoryComponent>()); }