Example #1
0
 private void OnEnable()
 {
     list = new ReorderableList(serializedObject, serializedObject.FindProperty("brushes")
                                , false, true, true, true);
     list.drawElementCallback += DrawBrush;
     list.onSelectCallback += SelectElemet;
 }
Example #2
0
    private void parseFiltersList()
    {
        filtersList = new ReorderableList(serializedObject,
                serializedObject.FindProperty("Filters"),
                false, true, true, true);

        filtersList.drawHeaderCallback = (Rect rect) => {
            EditorGUI.LabelField(rect, "Filters");
        };
        filtersList.drawElementCallback += (rect, index, active, focused) =>
        {
            rect.y += 2;
            var element = filtersList.serializedProperty.GetArrayElementAtIndex(index);
            EditorGUI.PropertyField(rect, element, GUIContent.none);

            filtersList.elementHeight = Math.Max(filtersList.elementHeight, EditorGUI.GetPropertyHeight(element) + 20);
        };
        filtersList.onAddCallback = (ReorderableList l) => {
            var index = l.serializedProperty.arraySize;
            l.serializedProperty.arraySize++;
            l.index = index;
            var element = l.serializedProperty.GetArrayElementAtIndex(index);
            element.FindPropertyRelative("Include").ClearArray();
            element.FindPropertyRelative("Exclude").ClearArray();
        };
        filtersList.onCanRemoveCallback = (ReorderableList l) => {
            return l.count > 1;
        };
        filtersList.onRemoveCallback = (ReorderableList l) => {
            if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete the wave?", "Yes", "No"))
            {
                ReorderableList.defaultBehaviours.DoRemoveButton(l);
            }
        };
    }
    void OnEnable()
    {
        lWidth = EditorGUIUtility.labelWidth;
        pf = target as PathFollower;

        list = new ReorderableList(serializedObject, serializedObject.FindProperty("path"), true, true, true, true);

        // Tell the list how to render it's contents
        list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
        {
            var element = list.serializedProperty.GetArrayElementAtIndex(index);
            EditorGUIUtility.labelWidth = 14f;

            rect.width /= 3;
            EditorGUI.LabelField(rect, string.Format("Point {0}", index));
            rect.x += rect.width;
            EditorGUI.PropertyField(rect, element.FindPropertyRelative("x"), new GUIContent("X"));
            rect.x += rect.width;
            EditorGUI.PropertyField(rect, element.FindPropertyRelative("y"), new GUIContent("Y"));
            EditorGUIUtility.labelWidth = lWidth;
        };
        list.drawHeaderCallback = (Rect rect) =>
        {
            EditorGUI.LabelField(rect, "Path Points");
        };
        list.onSelectCallback = (ReorderableList l) =>
        {
            SceneView.RepaintAll();
        };
        labelStyle = new GUIStyle();
        labelStyle.fontSize = 16;
        labelStyle.fontStyle = FontStyle.Bold;
    }
Example #4
0
    private void OnEnable()
    {
        _reorderableLists = new Dictionary<string, ReorderableList>();

        SerializedProperty iter = serializedObject.GetIterator();

        iter.Next(true);

        while (iter.NextVisible(false))
        {
            //Debug.Log(iter.propertyPath + " : " + iter.propertyType);
            if (iter.isArray)
            {
                ReorderableList list = new ReorderableList(iter.serializedObject, iter.Copy(), true, true, true, true);
                _reorderableLists.Add(iter.propertyPath, list);

                list.drawElementCallback = (Rect rect, int index, bool active, bool focused) =>
                {
                    var element = list.serializedProperty.GetArrayElementAtIndex(index);
                    rect.y += 2;
                    EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element);
                };

                list.drawHeaderCallback = (Rect rect) =>
                {
                    EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), list.serializedProperty.displayName);
                };
            }
        }
    }
	protected override void OnEnable ()
	{
		base.OnEnable ();
		bonusList = new ReorderableList(serializedObject, 
		                                     serializedObject.FindProperty("bonus"), 
		                                     true, true, true, true);
		bonusList.drawElementCallback =  (Rect rect, int index, bool isActive, bool isFocused) => {
			var element = bonusList.serializedProperty.GetArrayElementAtIndex(index);
			SerializedProperty nameProperty=element.FindPropertyRelative("name");
			SerializedProperty minProperty=element.FindPropertyRelative("minValue");
			SerializedProperty maxProperty=element.FindPropertyRelative("maxValue");
			rect.y += 2;
			rect.height=EditorGUIUtility.singleLineHeight;
			rect.width-=110f;
			EditorGUI.PropertyField(rect,nameProperty,GUIContent.none);
			rect.x+=rect.width+5;
			rect.width=50f;
			EditorGUI.PropertyField(rect,minProperty,GUIContent.none);
			rect.x+=rect.width+5;
			rect.width=50f;
			EditorGUI.PropertyField(rect,maxProperty,GUIContent.none);



		};
		bonusList.drawHeaderCallback = (Rect rect) => {  
			EditorGUI.LabelField(rect, "Attribute Bonus");
		};
	}
	private void OnEnable(){
		if (!(target is State)) {
			return;
		}
		state = (State)target;
		stateList = new ReorderableList (state.GetType().ToString().Split('.').Last());
		stateFields = state.GetType ()
			.GetFields (BindingFlags.Public | BindingFlags.Instance)
			.Where (x => x.DeclaringType.IsSubclassOf (typeof(State)))
			.ToArray();

		object[] attributes=state.GetType().GetCustomAttributes(true);
		bool isTrigger=false;
		foreach(object attribute in attributes){
			if(attribute is TriggerAttribute){
				isTrigger=true;
			}
		}

		if (!isTrigger) {
			actionList = new ReorderableList (state.actions, "Actions", true);
			actionList.onAddCallback = AddAction;
			actionList.onRemoveCallback = RemoveAction;
			actionList.drawElementCallback = DrawActionElement;
			actionList.onHeaderClick = OnActionHeaderClick;
		}

		transitionList = new ReorderableList (state.transitions, "Transitions", true,false,false);
		transitionList.onRemoveCallback = RemoveTransition;
		transitionList.drawElementCallback = DrawTransitionElement;
		transitionList.onSelectCallback = TransitionSelected;

	}
Example #7
0
 private void OnEnable()
 {
     _list = new ReorderableList(serializedObject, serializedObject.FindProperty("_nodes"), true, true, false, false);
     _list.drawHeaderCallback += DrawHeader;
     _list.drawElementCallback += DrawElement;
     _list.onReorderCallback += Reorder;
 }
	protected override void OnEnable(){
		base.OnEnable ();
		ingredientList = new ReorderableList(serializedObject, 
		                               serializedObject.FindProperty("ingredients"), 
		                               true, true, true, true);
		ingredientList.drawElementCallback =  (Rect rect, int index, bool isActive, bool isFocused) => {
			var element = ingredientList.serializedProperty.GetArrayElementAtIndex(index);
			SerializedProperty itemProperty=element.FindPropertyRelative("item");
			rect.y += 2;
			rect.height=EditorGUIUtility.singleLineHeight;

			string itemName=itemProperty.objectReferenceValue!= null?(itemProperty.objectReferenceValue as InventoryItem).itemName:string.Empty;
			Color color = GUI.backgroundColor;
			GUI.backgroundColor = itemProperty.objectReferenceValue == null ? Color.red : color;
			rect.width-=55f;
			itemName=EditorGUI.TextField(rect,itemName);
			GUI.backgroundColor = color;
			BaseItem item=database.GetItem(itemName);
			itemProperty.objectReferenceValue = item;
			rect.x+=rect.width+5;
			rect.width=50f;
			SerializedProperty amount=element.FindPropertyRelative("amount");
			EditorGUI.PropertyField(rect,amount,GUIContent.none);
			amount.intValue=Mathf.Clamp(amount.intValue,1,int.MaxValue);
		};
		ingredientList.drawHeaderCallback = (Rect rect) => {  
			EditorGUI.LabelField(rect, "Ingredients");
		};
	}
	private void OnEnable()
	{
		numberOfItems = 3;
		list = new ReorderableList(serializedObject, serializedObject.FindProperty("eventAction"),true,true,true,true);
		list.drawHeaderCallback =  
		(Rect rect) => {
			GUI.Label(rect, "Event Actions");
		};
		list.drawElementCallback =  
		(Rect rect, int index, bool isActive, bool isFocused) => {
			//get property
			var element = list.serializedProperty.GetArrayElementAtIndex(index);
			rect = new Rect(rect.x,rect.y, rect.width,EditorGUIUtility.singleLineHeight);
			//layout shit
			DrawEventActionPopup(element, rect);
			rect.y = rect.y + gap;
			DrawPlaybackActions(element, rect);
			DrawMixerActions(element, rect);
			rect.y = rect.y + gap;
			if (element.FindPropertyRelative("bypassEvent").boolValue)
			{
				rect.y = rect.y + gap;
				GUI.color = Color.green;
				DrawSwitchStatePopup(element, rect);
				GUI.color = Color.white;
			}
		};
		eNode = target as EventNode;
	}
 protected virtual void OnDisable() {
     if (reorderableList == null) return;
     reorderableList.drawElementCallback -= DrawElement;
     reorderableList.drawHeaderCallback -= DrawHeader;
     reorderableList.onAddCallback += OnItemAdded;
     reorderableList = null;
 }
	private void DrawElementCallback(Rect position, ReorderableList reorderableList, int index)
	{
		if (index < reorderableList.serializedProperty.arraySize)
		{
			EditorGUI.PropertyField(position, reorderableList.serializedProperty.GetArrayElementAtIndex(index));
		}
	}
 private void OnAddDropDown(Rect buttonRect, ReorderableList list)
 {
     var menu = new GenericMenu();
     if (kModule._inputData.Length >= 2) return;
     if (kModule._inputData.Length == 0)
     {
         menu.AddItem(new GUIContent("Right Hand"),
                  false, OnClickHandler,
                  new DataParams() { jointType = KinectUIHandType.Right });
         menu.AddItem(new GUIContent("Left Hand"),
                  false, OnClickHandler,
                  new DataParams() { jointType = KinectUIHandType.Left });
     }
     else if (kModule._inputData.Length == 1)
     {
         DataParams param;
         string name;
         if (kModule._inputData[0].trackingHandType == KinectUIHandType.Left){
             param = new DataParams() { jointType = KinectUIHandType.Right };
             name = "Right Hand";
         }
         else
         {
             param = new DataParams() { jointType = KinectUIHandType.Left };
             name = "Left Hand";
         }
         menu.AddItem(new GUIContent(name),false, OnClickHandler, param);
     }
     menu.ShowAsContext();
 }
Example #13
0
	protected void OnEnable()
	{
		prop_startingTags = serializedObject.FindProperty("startingTags");

		startingTags = new ReorderableList(serializedObject, prop_startingTags, false, true, true, true);
		startingTags.drawHeaderCallback += OnDrawHeader;
		startingTags.drawElementCallback += OnDrawElement;
	}
 protected ReorderableList GetList(SerializedProperty property) {
     if (reorderableList != null) return reorderableList;
     reorderableList = new ReorderableList(property.serializedObject, property, true, true, true, true);
     reorderableList.drawHeaderCallback += DrawHeader;
     reorderableList.drawElementCallback += DrawElement;
     reorderableList.onAddCallback += OnItemAdded;
     return reorderableList;
 }
    private void OnEnable()
    {
        _list = new ReorderableList(serializedObject,
                serializedObject.FindProperty("_pages"),
                true, true, true, true);

        _list.drawElementCallback = DrawListCallBack;
        _list.elementHeight = EditorGUIUtility.singleLineHeight * 7f;
    }
        public void Init(ReorderableList extList)
        {
            _extList = extList;
            _rect = GetComponent<RectTransform>();
            _cachedChildren = new List<Transform>();
            _cachedListElement = new List<ReorderableListElement>();

            StartCoroutine(RefreshChildren());
        }
	void OnEnable()
	{
		single = serializedObject.FindProperty("m_Single");
		array = new ReorderableList(serializedObject, serializedObject.FindProperty("m_Array"));
		array.drawHeaderCallback = position => EditorGUI.LabelField(position, "Array");
		array.drawElementCallback =
			(position, index, isActive, isFocused) => DrawElementCallback(position, array, index);
		array.elementHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
	}
 private void AddElement(ReorderableList _list)
 {
     var index = _list.serializedProperty.arraySize;
     _list.serializedProperty.arraySize++;
     _list.index = index;
     SerializedProperty raceProperty = _list.serializedProperty.GetArrayElementAtIndex(index);
     raceProperty.FindPropertyRelative("raceName").stringValue = "(Race)";
     raceProperty.FindPropertyRelative("avatars").arraySize = 0;
 }
 private void ElementDropped(ReorderableList.ReorderableListEventStruct droppedStruct)
 {
     DebugLabel.text = "";
     DebugLabel.text += "Dropped Object: " + droppedStruct.DroppedObject.name + "\n";
     DebugLabel.text += "Is Clone ?: " + droppedStruct.IsAClone + "\n";
     if (droppedStruct.IsAClone)
         DebugLabel.text += "Source Object: " + droppedStruct.SourceObject.name + "\n";
     DebugLabel.text += string.Format("From {0} at Index {1} \n", droppedStruct.FromList.name, droppedStruct.FromIndex);
     DebugLabel.text += string.Format("To {0} at Index {1} \n", droppedStruct.ToList.name, droppedStruct.ToIndex);
 }
Example #20
0
 protected void InitParamList(AiBehaviour blackboard)
 {
     _serializedObject = new SerializedObject(blackboard);
     var p = _serializedObject.FindProperty("_parameters").FindPropertyRelative(_mainPropertyName);
     _list = new ReorderableList(_serializedObject, p.FindPropertyRelative(_keysPropertyName), true, true, true, true);
     _list.drawHeaderCallback += DrawHeader;
     _list.onAddCallback += Add;
     _list.onRemoveCallback += Remove;
     _list.drawElementCallback += DrawElement;
 }
Example #21
0
 public override void Add(ReorderableList list)
 {
     string k = _keyName;
     int i = 0;
     while (((AiBehaviour)_serializedObject.targetObject).Blackboard.IntParameters.ContainsKey(k)) {
         k = _keyName + " " + (i++).ToString();
     }
     ((AiBehaviour)_serializedObject.targetObject).Blackboard.IntParameters[k] = 0;
     Selection.activeObject = _serializedObject.targetObject;
 }
 private ReorderableList ListMaker(SerializedObject obj)
 {
     ReorderableList newList = new ReorderableList(obj, obj.FindProperty("values"), true, false, true, true);
     list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
         SerializedProperty element = newList.serializedProperty.GetArrayElementAtIndex(index);
         rect.y += 2;
         EditorGUI.PropertyField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("key"), GUIContent.none);
         EditorGUI.PropertyField(new Rect(rect.x + 70, rect.y, 160, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("values"), GUIContent.none);
     };
     return newList;
 }
Example #23
0
 private void OnEnable()
 {
     minPoolIdsProp = serializedObject.FindProperty ("minPooledIds");
     list = new ReorderableList(serializedObject,
             serializedObject.FindProperty("poolablePrefabs"),
             true, true, true, true);
     list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
         var element = list.serializedProperty.GetArrayElementAtIndex(index);
         rect.y += 2;
         EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, GUIContent.none);
     };
 }
    public AvatarListEditor(SerializedObject serializedObject, SerializedProperty serializedList, SerializedProperty serializedName)
    {
        name = serializedName;

        list = new ReorderableList(serializedObject,
        serializedList,
        true, false, true, true);
        list.headerHeight = 0;
        list.elementHeight = EditorGUIUtility.singleLineHeight + 5;
        list.drawElementCallback = DrawElement;
        list.showDefaultBackground = false;
    }
    void OnEnable()
    {
        kModule = target as KinectInputModule;
        list = new ReorderableList(serializedObject, serializedObject.FindProperty("_inputData"), true, true, true, true);
        list.drawHeaderCallback += OnDrawHeader;
        list.drawElementCallback += OnDrawElements;
        list.onAddDropdownCallback += OnAddDropDown;

        _scrollSpeed = serializedObject.FindProperty("_scrollSpeed");
        _scrollTreshold = serializedObject.FindProperty("_scrollTreshold");
        _waitOverTime = serializedObject.FindProperty("_waitOverTime");
    }
    private void Initialize() {
        if ( list == null ) {
            mTarget = target as Pentagram;
            values = mTarget.Qu;

            list = new ReorderableList( values, typeof( PentaInfo ), true, true, true, true );
            list.elementHeight *= 2;
            list.onAddCallback = new ReorderableList.AddCallbackDelegate( OnAdd );
            list.onRemoveCallback = new ReorderableList.RemoveCallbackDelegate( OnRemove );
            list.drawElementCallback = new ReorderableList.ElementCallbackDelegate( OnDrawElement );

        }
    }
 private void Draw(bool draggable, bool displayHeader,
     bool displayAddButton, bool displayRemoveButton, string propertyName)
 {
     if (!lists.ContainsKey(propertyName))
     {
         var list = new ReorderableList(serializedObject, serializedObject.FindProperty(propertyName), draggable, displayHeader, displayAddButton, displayRemoveButton);
         lists.Add(propertyName, list);
     }
     else
     {
         lists[propertyName].DoList();
     }
 }
	protected virtual void OnEnable(){
		if ((target as AttributeHandler).transform.root.GetComponent<AttributeHandler> ()== null) {
			(target as AttributeHandler).transform.root.gameObject.AddComponent<AttributeHandler>();
		}
		list = serializedObject.FindProperty ("attributes");
		if ((target as AttributeHandler).attributes == null) {
			(target as AttributeHandler).attributes= new List<ObjectAttribute>();
		}
		mList = new ReorderableList ((target as AttributeHandler).attributes, "Attributes", false, true){
			drawElementCallback = new ReorderableList.ElementCallbackDelegate (this.OnDrawElement),
			onAddCallback= new ReorderableList.AddCallbackDelegate(this.AddElement)
		};
	}
	private void OnEnable() {
		list = new ReorderableList(serializedObject, 
		                           serializedObject.FindProperty("Waves"), 
		                           true, true, true, true);
		list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
			var element = list.serializedProperty.GetArrayElementAtIndex(index);
			rect.y += 2;
			EditorGUI.PropertyField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Type"), GUIContent.none);
			EditorGUI.PropertyField(new Rect(rect.x + 60, rect.y, rect.width - 60 - 30, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Prefab"), GUIContent.none);
			EditorGUI.PropertyField(new Rect(rect.x + rect.width - 30, rect.y, 30, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Count"), GUIContent.none);
		};
		list.drawHeaderCallback = (Rect rect) => {
			EditorGUI.LabelField(rect, "Monster Waves");
		};
		list.onSelectCallback = (ReorderableList l) => {
			var prefab = l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("Prefab").objectReferenceValue as GameObject;
			if (prefab) EditorGUIUtility.PingObject(prefab.gameObject);
		};
		list.onCanRemoveCallback = (ReorderableList l) => {
			return l.count > 1;
		};
		list.onRemoveCallback = (ReorderableList l) => {
			if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete the wave?", "Yes", "No"))
			{
				ReorderableList.defaultBehaviours.DoRemoveButton(l);
			}
		};
		list.onAddCallback = (ReorderableList l) => {
			var index = l.serializedProperty.arraySize;
			l.serializedProperty.arraySize++;
			l.index = index;
			var element = l.serializedProperty.GetArrayElementAtIndex(index);
			element.FindPropertyRelative("Type").enumValueIndex = 0;
			element.FindPropertyRelative("Count").intValue = 20;
			element.FindPropertyRelative("Prefab").objectReferenceValue = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Mobs/Cube.prefab", typeof(GameObject)) as GameObject;
		};
		list.onAddDropdownCallback = (Rect buttonRect, ReorderableList l) => {
			var menu = new GenericMenu();
			var guids = AssetDatabase.FindAssets("", new[]{"Assets/Prefabs/Mobs"});
			foreach (var guid in guids) {
				var path = AssetDatabase.GUIDToAssetPath(guid);
				menu.AddItem(new GUIContent("Mobs/" + Path.GetFileNameWithoutExtension(path)), false, clickHandler, new WaveCreationParams() {Type = MobWave.WaveType.Mobs, Path = path});
			}
			guids = AssetDatabase.FindAssets("", new[]{"Assets/Prefabs/Bosses"});
			foreach (var guid in guids) {
				var path = AssetDatabase.GUIDToAssetPath(guid);
				menu.AddItem(new GUIContent("Bosses/" + Path.GetFileNameWithoutExtension(path)), false, clickHandler, new WaveCreationParams() {Type = MobWave.WaveType.Boss, Path = path});
			}
			menu.ShowAsContext();
		};
	}
    void OnEnable()
    {
        _spellList = serializedObject.FindProperty("_spells");

        _list = new ReorderableList(serializedObject, _spellList, true, true, true, true);
        _list.displayAdd = false;

        _list.drawHeaderCallback = (Rect rect) =>
        {
            EditorGUI.LabelField(rect, "Spells");
        };

        _list.drawElementCallback = ListDrawCallBack;
    }
        private void InitReorderLists()
        {
            portLists = new ReorderableList[linkPorts.Length];
            for (int i = 0; i < portLists.Length; i++)
            {
                var id   = i;
                var port = linkPorts[i];
                port.connectAble.Sort();

                portLists[i] = new ReorderableList(port.connectAble, typeof(LinkInfo));
                portLists[i].drawHeaderCallback = (rect) =>
                {
                    var nameRect  = new Rect(rect.x + 15, rect.y, rect.width * 0.4f, EditorGUIUtility.singleLineHeight);
                    var idRect    = new Rect(rect.x + rect.width * 0.4f, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    var rangeRect = new Rect(rect.x + rect.width * 0.55f, rect.y, 60, EditorGUIUtility.singleLineHeight);

                    EditorGUI.LabelField(nameRect, string.Format("目标({0}:{1})", port.name, port.NodeID));
                    EditorGUI.LabelField(idRect, "端口");
                    EditorGUI.BeginChangeCheck();
                    port.Range  = GUI.HorizontalSlider(rangeRect, port.Range, 0.1f, 2);
                    port.NodeID = id;
                    port.InitLayer();
                    if (EditorGUI.EndChangeCheck())
                    {
                        port.Range = (float)System.Math.Round(port.Range, 2);
                    }
                    var btnRect = new Rect(rect.x + rect.width - buttonWidth * 2f, rect.y, buttonWidth, EditorGUIUtility.singleLineHeight);

                    if (GUI.Button(btnRect, "Record"))
                    {
                        List <LinkPort> otherPorts;
                        if (LinkUtil.FindTriggerNodes(port, out otherPorts))
                        {
                            if (otherPorts != null && otherPorts.Count > 0)
                            {
                                var window = EditorWindow.GetWindow <LinkWindow>();
                                window.InitPortGroup(port, otherPorts.ToArray());
                            }
                        }
                    }
                    btnRect.x += buttonWidth;
                    if (GUI.Button(btnRect, "Link"))
                    {
                        if (Selection.activeGameObject != null)
                        {
                            var linkport = Selection.activeGameObject.GetComponentInParent <LinkPort>();
                            if (linkport != null)
                            {
                                var linkItem = linkport.GetComponentInParent <LinkItem>();
                                var linkInfo = port.connectAble.Find(x => x.itemName == linkItem.Name && x.nodeId == linkport.NodeID);
                                if (linkInfo != null)
                                {
                                    LinkUtil.ResetTargetTranform(targetItem, linkItem, linkInfo.relativePos, linkInfo.relativeDir);
                                }
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("温馨提示", "请选择目标端口后重试", "确认");
                            }
                        }
                    }
                };
                portLists[i].drawElementCallback = (rect, index, isactive, isfoces) =>
                {
                    var linkInfo = port.connectAble[index];
                    var nameRect = new Rect(rect.x, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(nameRect, linkInfo.itemName);
                    var idRect = new Rect(rect.x + rect.width * 0.4f, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(idRect, linkInfo.nodeId.ToString());
                    var rangeRect = new Rect(rect.x + rect.width * 0.55f, rect.y, 60, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(rangeRect, port.Range.ToString());
                };
            }
        }
 private void OnClickRemoveBtn(ReorderableList targetList)
 {
     // Remove cell.
     _editor.model.symbols.RemoveAt(targetList.index);
     _edited = true;
 }
Example #33
0
    private void OnEnable()
    {
        // Get Target
        m_target = (TilemapSystem3D)target;

        // Refresh the render material
        if (m_target.tilemapData)
        {
            m_target.UpdateRenderMaterial();
        }

        // Update layer intensity
        m_target.UpdateLayerSettings();

        // Find the serialized properties
        m_showReferencesGroup         = serializedObject.FindProperty("showReferencesGroup");
        m_showSettingsGroup           = serializedObject.FindProperty("showSettingsGroup");
        m_showDataGroup               = serializedObject.FindProperty("showDataGroup");
        m_showPantingGroup            = serializedObject.FindProperty("showPantingGroup");
        m_showAutoTileGroup           = serializedObject.FindProperty("showAutoTileGroup");
        m_showRandomTilePaintingGroup = serializedObject.FindProperty("showRandomTilePaintingGroup");
        m_showRandomizeTileGroup      = serializedObject.FindProperty("showRandomizeTileGroup");
        m_showTileBrushesGroup        = serializedObject.FindProperty("showTileBrushesGroup");
        m_showAboutGroup              = serializedObject.FindProperty("showAboutGroup");
        m_legacyShader    = serializedObject.FindProperty("legacyShader");
        m_universalShader = serializedObject.FindProperty("universalShader");
        m_tilemapData     = serializedObject.FindProperty("tilemapData");
        m_renderPipeline  = serializedObject.FindProperty("renderPipeline");
        m_tilesetSize     = serializedObject.FindProperty("tilesetSize");
        m_paintingMode    = serializedObject.FindProperty("paintingMode");

        m_paintingToolIcons = new[]
        {
            EditorGUIUtility.FindTexture("Grid.PickingTool"),
            EditorGUIUtility.FindTexture("Grid.PaintTool"),
            EditorGUIUtility.FindTexture("Grid.FillTool"),
            EditorGUIUtility.FindTexture("Grid.EraserTool")
        };

        // Layer list
        m_tilemapLayerList            = serializedObject.FindProperty("tilemapLayerList");
        m_reorderableTilemapLayerList = new ReorderableList(serializedObject, m_tilemapLayerList, false, true, true, true)
        {
            drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                // Initialize
                var element = m_reorderableTilemapLayerList.serializedProperty.GetArrayElementAtIndex(index);

                // Draw the image icon
                if (m_target.tilemapLayerList[index].tilePalette)
                {
                    m_layerIconTexture = m_target.tilemapLayerList[index].tilePalette.temporaryTileTextureArray[1];
                }
                if (m_layerIconTexture == null)
                {
                    m_layerIconTexture = emptyIconTexture;
                }
                GUI.DrawTexture(new Rect(rect.x, rect.y + 2, 38, 38), m_layerIconTexture, ScaleMode.StretchToFill, true, 0);
                m_layerIconTexture = null;

                // Draw the name field
                EditorGUI.PropertyField(new Rect(rect.x + 42, rect.y + 1, rect.width - 85, 18), element.FindPropertyRelative("layerName"), GUIContent.none);

                // Draw the alpha intensity slider
                EditorGUI.Slider(new Rect(rect.x + 42, rect.y + 22, rect.width - 85, 18), element.FindPropertyRelative("intensity"), 0.0f, 1.0f, GUIContent.none);

                // Copy button
                if (GUI.Button(new Rect(rect.width - 18, rect.y + 1, 22, 41), "C"))
                {
                    m_target.CopyTilemapLayer(index);
                }

                // Paste button
                if (GUI.Button(new Rect(rect.width + 4, rect.y + 1, 22, 41), "P"))
                {
                    m_target.PasteTilemapLayer(index);
                }

                // Create the reorderable auto tile list for this layer and save it to the dictionary
                if (!m_autoTileDictionary.ContainsKey(index))
                {
                    m_autoTileDictionary[index] = CreateAutoTileList(element.FindPropertyRelative("autoTileList"));
                }
            },

            onAddCallback = (ReorderableList l) =>
            {
                var index = l.serializedProperty.arraySize;
                ReorderableList.defaultBehaviours.DoAddButton(l);
                var element = l.serializedProperty.GetArrayElementAtIndex(index);
                element.FindPropertyRelative("layerName").stringValue            = "Layer " + index;
                element.FindPropertyRelative("intensity").floatValue             = 1.0f;
                element.FindPropertyRelative("tilePalette").objectReferenceValue = null;
                element.FindPropertyRelative("autoTileList").ClearArray();
                ResetAutoTileArrayMap(element.FindPropertyRelative("autoTileMapArray"));
            },

            onRemoveCallback = (ReorderableList l) =>
            {
                m_target.layerIndex--;
                ReorderableList.defaultBehaviours.DoRemoveButton(l);
            },

            drawHeaderCallback = (Rect rect) =>
            {
                EditorGUI.LabelField(rect, m_guiContent[3], EditorStyles.boldLabel);
            },

            elementHeightCallback = (int index) => 44,

            drawElementBackgroundCallback = (rect, index, active, focused) =>
            {
                if (active)
                {
                    GUI.Box(new Rect(rect.x + 2, rect.y - 1, rect.width - 4, rect.height + 1), "", "selectionRect");
                }
            }
        };

        if (m_reorderableTilemapLayerList.count > 0)
        {
            m_reorderableTilemapLayerList.index = 0;
        }
    }
 void OnRemoveInitializationObject(ReorderableList list)
 {
     m_AasTarget.RemoveInitializationObject(list.index);
 }
 void OnRemoveCallback(ReorderableList list)
 {
     ReorderableList.defaultBehaviours.DoRemoveButton(list);
 }
Example #36
0
 protected override void OnElementNameChanged(ReorderableList r, int index, string newName)
 {
     Controller.getInstance().getSelectedChapterDataControl().getObjects <QR>()[index].Id = newName;
 }
Example #37
0
 protected override void OnAdd(ReorderableList r)
 {
     Controller.getInstance().getSelectedChapterDataControl().getObjects <QR>().Add(new QR("newQRCode"));
 }
Example #38
0
        private static ReorderableList CreateReorderableList(string fieldName, List <XNode.NodePort> dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint, Action <ReorderableList> onCreation)
        {
            bool hasArrayData = arrayData != null && arrayData.isArray;

            XNode.Node      node  = serializedObject.targetObject as XNode.Node;
            ReorderableList list  = new ReorderableList(dynamicPorts, null, true, true, true, true);
            string          label = arrayData != null ? arrayData.displayName : ObjectNames.NicifyVariableName(fieldName);

            list.drawElementCallback =
                (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                XNode.NodePort port = node.GetPort(fieldName + " " + index);
                if (hasArrayData)
                {
                    if (arrayData.arraySize <= index)
                    {
                        string portInfo = port != null ? port.fieldName : "";
                        EditorGUI.LabelField(rect, "Array[" + index + "] data out of range");
                        return;
                    }
                    SerializedProperty itemData = arrayData.GetArrayElementAtIndex(index);
                    EditorGUI.PropertyField(rect, itemData, true);
                }
                else
                {
                    EditorGUI.LabelField(rect, port != null ? port.fieldName : "");
                }

                if (port != null)
                {
                    Vector2 pos = rect.position + (port.IsOutput?new Vector2(rect.width + 6, 0) : new Vector2(-36, 0));
                    NodeEditorGUILayout.PortField(pos, port);
                }
            };
            list.elementHeightCallback =
                ( int index ) =>
            {
                if (hasArrayData)
                {
                    if (arrayData.arraySize <= index)
                    {
                        return(EditorGUIUtility.singleLineHeight);
                    }

                    SerializedProperty itemData = arrayData.GetArrayElementAtIndex(index);
                    return(EditorGUI.GetPropertyHeight(itemData));
                }
                else
                {
                    return(EditorGUIUtility.singleLineHeight);
                }
            };
            list.drawHeaderCallback =
                ( Rect rect ) =>
            {
                EditorGUI.LabelField(rect, label);
            };
            list.onSelectCallback =
                ( ReorderableList rl ) =>
            {
                reorderableListIndex = rl.index;
            };
            list.onReorderCallback =
                ( ReorderableList rl ) =>
            {
                // Move up
                if (rl.index > reorderableListIndex)
                {
                    for (int i = reorderableListIndex; i < rl.index; ++i)
                    {
                        XNode.NodePort port     = node.GetPort(fieldName + " " + i);
                        XNode.NodePort nextPort = node.GetPort(fieldName + " " + (i + 1));
                        port.SwapConnections(nextPort);

                        // Swap cached positions to mitigate twitching
                        Rect rect = NodeEditorWindow.current.portConnectionPoints[port];
                        NodeEditorWindow.current.portConnectionPoints[port]     = NodeEditorWindow.current.portConnectionPoints[nextPort];
                        NodeEditorWindow.current.portConnectionPoints[nextPort] = rect;
                    }
                }
                // Move down
                else
                {
                    for (int i = reorderableListIndex; i > rl.index; --i)
                    {
                        XNode.NodePort port     = node.GetPort(fieldName + " " + i);
                        XNode.NodePort nextPort = node.GetPort(fieldName + " " + (i - 1));
                        port.SwapConnections(nextPort);

                        // Swap cached positions to mitigate twitching
                        Rect rect = NodeEditorWindow.current.portConnectionPoints[port];
                        NodeEditorWindow.current.portConnectionPoints[port]     = NodeEditorWindow.current.portConnectionPoints[nextPort];
                        NodeEditorWindow.current.portConnectionPoints[nextPort] = rect;
                    }
                }
                // Apply changes
                serializedObject.ApplyModifiedProperties();
                serializedObject.Update();

                // Move array data if there is any
                if (hasArrayData)
                {
                    arrayData.MoveArrayElement(reorderableListIndex, rl.index);
                }

                // Apply changes
                serializedObject.ApplyModifiedProperties();
                serializedObject.Update();
                NodeEditorWindow.current.Repaint();
                EditorApplication.delayCall += NodeEditorWindow.current.Repaint;
            };
            list.onAddCallback =
                ( ReorderableList rl ) =>
            {
                // Add dynamic port postfixed with an index number
                string newName = fieldName + " 0";
                int    i       = 0;
                while (node.HasPort(newName))
                {
                    newName = fieldName + " " + (++i);
                }

                if (io == XNode.NodePort.IO.Output)
                {
                    node.AddDynamicOutput(type, connectionType, XNode.Node.TypeConstraint.None, newName);
                }
                else
                {
                    node.AddDynamicInput(type, connectionType, typeConstraint, newName);
                }

                serializedObject.Update();
                EditorUtility.SetDirty(node);
                if (hasArrayData)
                {
                    arrayData.InsertArrayElementAtIndex(arrayData.arraySize);
                }
                serializedObject.ApplyModifiedProperties();
            };
            list.onRemoveCallback =
                ( ReorderableList rl ) =>
            {
                var indexedPorts = node.DynamicPorts.Select(x =>
                {
                    string[] split = x.fieldName.Split(' ');
                    if (split != null && split.Length == 2 && split[0] == fieldName)
                    {
                        int i = -1;
                        if (int.TryParse(split[1], out i))
                        {
                            return(new { index = i, port = x });
                        }
                    }
                    return(new { index = -1, port = (XNode.NodePort)null });
                });
                dynamicPorts = indexedPorts.OrderBy(x => x.index).Select(x => x.port).ToList();

                int index = rl.index;

                if (dynamicPorts[index] == null)
                {
                    Debug.LogWarning("No port found at index " + index + " - Skipped");
                }
                else if (dynamicPorts.Count <= index)
                {
                    Debug.LogWarning("DynamicPorts[" + index + "] out of range. Length was " + dynamicPorts.Count + " - Skipped");
                }
                else
                {
                    // Clear the removed ports connections
                    dynamicPorts[index].ClearConnections();
                    // Move following connections one step up to replace the missing connection
                    for (int k = index + 1; k < dynamicPorts.Count(); k++)
                    {
                        for (int j = 0; j < dynamicPorts[k].ConnectionCount; j++)
                        {
                            XNode.NodePort other = dynamicPorts[k].GetConnection(j);
                            dynamicPorts[k].Disconnect(other);
                            dynamicPorts[k - 1].Connect(other);
                        }
                    }
                    // Remove the last dynamic port, to avoid messing up the indexing
                    node.RemoveDynamicPort(dynamicPorts[dynamicPorts.Count() - 1].fieldName);
                    serializedObject.Update();
                    EditorUtility.SetDirty(node);
                }

                if (hasArrayData)
                {
                    if (arrayData.arraySize <= index)
                    {
                        Debug.LogWarning("Attempted to remove array index " + index + " where only " + arrayData.arraySize + " exist - Skipped");
                        Debug.Log(rl.list[0]);
                        return;
                    }
                    arrayData.DeleteArrayElementAtIndex(index);
                    // Error handling. If the following happens too often, file a bug report at https://github.com/Siccity/xNode/issues
                    if (dynamicPorts.Count <= arrayData.arraySize)
                    {
                        while (dynamicPorts.Count <= arrayData.arraySize)
                        {
                            arrayData.DeleteArrayElementAtIndex(arrayData.arraySize - 1);
                        }
                        UnityEngine.Debug.LogWarning("Array size exceeded dynamic ports size. Excess items removed.");
                    }
                    serializedObject.ApplyModifiedProperties();
                    serializedObject.Update();
                }
            };

            if (hasArrayData)
            {
                int dynamicPortCount = dynamicPorts.Count;
                while (dynamicPortCount < arrayData.arraySize)
                {
                    // Add dynamic port postfixed with an index number
                    string newName = arrayData.name + " 0";
                    int    i       = 0;
                    while (node.HasPort(newName))
                    {
                        newName = arrayData.name + " " + (++i);
                    }

                    if (io == XNode.NodePort.IO.Output)
                    {
                        node.AddDynamicOutput(type, connectionType, typeConstraint, newName);
                    }
                    else
                    {
                        node.AddDynamicInput(type, connectionType, typeConstraint, newName);
                    }

                    EditorUtility.SetDirty(node);
                    dynamicPortCount++;
                }
                while (arrayData.arraySize < dynamicPortCount)
                {
                    arrayData.InsertArrayElementAtIndex(arrayData.arraySize);
                }
                serializedObject.ApplyModifiedProperties();
                serializedObject.Update();
            }
            if (onCreation != null)
            {
                onCreation(list);
            }

            return(list);
        }
Example #39
0
 void rlOnChangedCallback(ReorderableList _rl)
 {
     // Uncomment the below line to display message when list has changed.
     // Debug.Log("List changed");
 }
        void InitializeBakingStatesList()
        {
            m_BakingStates                       = new ReorderableList(GetCurrentBakingSet().bakingStates, typeof(string), true, false, true, true);
            m_BakingStates.multiSelect           = false;
            m_BakingStates.elementHeightCallback = _ => EditorGUIUtility.singleLineHeight;
            m_BakingStates.drawElementCallback   = (rect, index, active, focused) =>
            {
                var bakingSet = GetCurrentBakingSet();

                // Status
                var status = bakingStatesStatuses[index];
                if (status != BakingStateStatus.Valid)
                {
                    var  label       = Styles.bakingStateStatusLabel[(int)status];
                    var  style       = status == BakingStateStatus.OutOfDate ? Styles.labelRed : EditorStyles.label;
                    Rect invalidRect = new Rect(rect)
                    {
                        xMin = rect.xMax - style.CalcSize(label).x - 3
                    };
                    rect.xMax = invalidRect.xMin;

                    using (new EditorGUI.DisabledScope(status != BakingStateStatus.OutOfDate))
                        EditorGUI.LabelField(invalidRect, label, style);
                }

                // Event
                string key = k_RenameFocusKey + index;
                if (Event.current.type == EventType.MouseDown && GUI.GetNameOfFocusedControl() != key)
                {
                    m_RenameSelectedBakingState = false;
                }
                if (Event.current.type == EventType.MouseDown && Event.current.clickCount == 2)
                {
                    if (rect.Contains(Event.current.mousePosition))
                    {
                        m_RenameSelectedBakingState = true;
                    }
                }
                if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
                {
                    m_RenameSelectedBakingState = false;
                }

                // Name
                var stateName = bakingSet.bakingStates[index];
                if (!m_RenameSelectedBakingState || !active)
                {
                    EditorGUI.LabelField(rect, stateName);
                }
                else
                {
                    // Renaming
                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName(key);
                    var name = EditorGUI.DelayedTextField(rect, stateName, EditorStyles.boldLabel);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_RenameSelectedBakingState = false;
                        if (AllSetScenesAreLoaded() || EditorUtility.DisplayDialog("Rename Baking State", "Some scenes in the baking set contain probe volumes but are not loaded.\nRenaming the baking state may require you to rebake the scene.", "Rename", "Cancel"))
                        {
                            try
                            {
                                AssetDatabase.StartAssetEditing();

                                foreach (var data in ProbeReferenceVolume.instance.perSceneDataList)
                                {
                                    if (bakingSet.sceneGUIDs.Contains(sceneData.GetSceneGUID(data.gameObject.scene)))
                                    {
                                        data.RenameBakingState(stateName, name);
                                    }
                                }
                                bakingSet.bakingStates[index]             = name;
                                ProbeReferenceVolume.instance.bakingState = name;
                            }
                            finally
                            {
                                AssetDatabase.StopAssetEditing();
                                foreach (var data in ProbeReferenceVolume.instance.perSceneDataList)
                                {
                                    data.ResolveCells();
                                }
                            }
                        }
                    }
                }
            };

            m_BakingStates.onSelectCallback = (ReorderableList list) =>
            {
                ProbeReferenceVolume.instance.bakingState = GetCurrentBakingSet().bakingStates[list.index];
                SceneView.RepaintAll();
                Repaint();
            };

            m_BakingStates.onReorderCallback = (ReorderableList list) => UpdateBakingStatesStatuses();

            m_BakingStates.onAddCallback = (list) =>
            {
                Undo.RegisterCompleteObjectUndo(sceneData.parentAsset, "Added new baking state");
                var state = GetCurrentBakingSet().CreateBakingState("New Baking State");
                m_BakingStates.index = GetCurrentBakingSet().bakingStates.IndexOf(state);
                m_BakingStates.onSelectCallback(m_BakingStates);
                UpdateBakingStatesStatuses();
            };

            m_BakingStates.onRemoveCallback = (list) =>
            {
                if (m_BakingStates.count == 1)
                {
                    EditorUtility.DisplayDialog("Can't delete baking state", "You can't delete the last Baking state. You need to have at least one.", "Ok");
                    return;
                }
                if (!EditorUtility.DisplayDialog("Delete the selected baking state?", $"Deleting the baking state will also delete corresponding baked data on disk.\nDo you really want to delete the baking state '{GetCurrentBakingSet().bakingStates[list.index]}'?\n\nYou cannot undo the delete assets action.", "Yes", "Cancel"))
                {
                    return;
                }
                var set   = GetCurrentBakingSet();
                var state = set.bakingStates[list.index];
                if (!set.RemoveBakingState(state))
                {
                    return;
                }
                try
                {
                    AssetDatabase.StartAssetEditing();
                    foreach (var data in ProbeReferenceVolume.instance.perSceneDataList)
                    {
                        if (set.sceneGUIDs.Contains(sceneData.GetSceneGUID(data.gameObject.scene)))
                        {
                            data.RemoveBakingState(state);
                        }
                    }
                }
                finally
                {
                    AssetDatabase.StopAssetEditing();
                    ProbeReferenceVolume.instance.bakingState = set.bakingStates[0];
                    UpdateBakingStatesStatuses();
                }
            };

            m_BakingStates.index = GetCurrentBakingSet().bakingStates.IndexOf(ProbeReferenceVolume.instance.bakingState);
            UpdateBakingStatesStatuses();
        }
        void OnBakingSetSelected(ReorderableList list)
        {
            // Update left panel data
            EditorPrefs.SetInt(k_SelectedBakingSetKey, list.index);
            var set = GetCurrentBakingSet();

            m_ScenesInSet = new ReorderableList(set.sceneGUIDs, typeof(string), true, true, true, true);
            m_ScenesInSet.drawHeaderCallback  = (rect) => EditorGUI.LabelField(rect, "Scenes", EditorStyles.largeLabel);
            m_ScenesInSet.multiSelect         = true;
            m_ScenesInSet.drawElementCallback = (rect, index, active, focused) =>
            {
                float CalcLabelWidth(GUIContent c, GUIStyle s) => c.image ? s.CalcSize(c).x - c.image.width + rect.height : s.CalcSize(c).x;

                var guid = set.sceneGUIDs[index];
                // Find scene name from GUID:
                var scene = FindSceneData(guid);

                var  sceneLabel     = (scene.asset != null) ? new GUIContent(scene.asset.name, Styles.sceneIcon) : Styles.sceneNotFound;
                Rect sceneLabelRect = new Rect(rect)
                {
                    width = CalcLabelWidth(sceneLabel, EditorStyles.boldLabel)
                };
                EditorGUI.LabelField(sceneLabelRect, sceneLabel, EditorStyles.boldLabel);
                if (Event.current.type == EventType.MouseDown && sceneLabelRect.Contains(Event.current.mousePosition))
                {
                    EditorGUIUtility.PingObject(scene.asset);
                }

                // display the probe volume icon in the scene if it have one
                Rect probeVolumeIconRect = rect;
                probeVolumeIconRect.xMin = rect.xMax - k_ProbeVolumeIconSize;
                if (sceneData.hasProbeVolumes.TryGetValue(scene.guid, out bool hasProbeVolumes) && hasProbeVolumes)
                {
                    EditorGUI.LabelField(probeVolumeIconRect, new GUIContent(Styles.probeVolumeIcon));
                }

                // Display the lighting settings of the first scene (it will be used for baking)
                if (index == 0)
                {
                    var   lightingLabel        = Styles.sceneLightingSettings;
                    float middle               = (sceneLabelRect.xMax + probeVolumeIconRect.xMin) * 0.5f;
                    Rect  lightingSettingsRect = new Rect(rect)
                    {
                        xMin = middle - CalcLabelWidth(lightingLabel, EditorStyles.label) * 0.5f
                    };
                    EditorGUI.LabelField(lightingSettingsRect, lightingLabel);
                }
            };
            m_ScenesInSet.onAddCallback = (list) =>
            {
                // TODO: replace this generic menu by a mini-window with a search bar
                var menu = new GenericMenu();

                RefreshSceneAssets();
                foreach (var scene in m_ScenesInProject)
                {
                    if (set.sceneGUIDs.Contains(scene.guid))
                    {
                        continue;
                    }

                    menu.AddItem(new GUIContent(scene.asset.name), false, () =>
                    {
                        TryAddScene(scene);
                    });
                }

                if (menu.GetItemCount() == 0)
                {
                    menu.AddDisabledItem(new GUIContent("No available scenes"));
                }

                menu.ShowAsContext();
            };
            m_ScenesInSet.onRemoveCallback = (list) =>
            {
                Undo.RegisterCompleteObjectUndo(sceneData.parentAsset, "Deleted scene in baking set");
                ReorderableList.defaultBehaviours.DoRemoveButton(list);
                UpdateSceneData(); // Should not be needed on top of the Update call.
                UpdateBakingStatesStatuses();
            };

            void TryAddScene(SceneData scene)
            {
                // Don't allow the same scene in two different sets
                Undo.RegisterCompleteObjectUndo(sceneData.parentAsset, "Added scene in baking set");
                var setWithScene = sceneData.bakingSets.FirstOrDefault(s => s.sceneGUIDs.Contains(scene.guid));

                if (setWithScene != null)
                {
                    if (EditorUtility.DisplayDialog("Move Scene to baking set", $"The scene '{scene.asset.name}' was already added in the baking set '{setWithScene.name}'. Do you want to move it to the current set?", "Yes", "Cancel"))
                    {
                        setWithScene.sceneGUIDs.Remove(scene.guid);
                        set.sceneGUIDs.Add(scene.guid);
                    }
                }
                else
                {
                    set.sceneGUIDs.Add(scene.guid);
                }

                sceneData.SyncBakingSetSettings();
                UpdateSceneData();
                UpdateBakingStatesStatuses();
            }

            InitializeBakingStatesList();
        }
        void InitializeBakingSetList()
        {
            m_BakingSets                     = new ReorderableList(sceneData.bakingSets, typeof(ProbeVolumeSceneData.BakingSet), false, false, true, true);
            m_BakingSets.multiSelect         = false;
            m_BakingSets.drawElementCallback = (rect, index, active, focused) =>
            {
                // Draw the renamable label for the baking set name
                string key = k_RenameFocusKey + index;
                if (Event.current.type == EventType.MouseDown && GUI.GetNameOfFocusedControl() != key)
                {
                    m_RenameSelectedBakingSet = false;
                }
                if (Event.current.type == EventType.MouseDown && Event.current.clickCount == 2)
                {
                    if (rect.Contains(Event.current.mousePosition))
                    {
                        m_RenameSelectedBakingSet = true;
                    }
                }
                if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
                {
                    m_RenameSelectedBakingSet = false;
                }

                var set = sceneData.bakingSets[index];

                if (m_RenameSelectedBakingSet)
                {
                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName(key);
                    set.name = EditorGUI.DelayedTextField(rect, set.name, EditorStyles.boldLabel);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_RenameSelectedBakingSet = false;

                        // Rename profile asset to match name:
                        AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(set.profile), set.name);
                        set.profile.name = set.name;
                    }
                }
                else
                {
                    EditorGUI.LabelField(rect, set.name, EditorStyles.boldLabel);
                }
            };
            m_BakingSets.elementHeightCallback = _ => EditorGUIUtility.singleLineHeight;
            m_BakingSets.onSelectCallback      = OnBakingSetSelected;

            m_BakingSets.onAddCallback = (list) =>
            {
                Undo.RegisterCompleteObjectUndo(sceneData.parentAsset, "Added new baking set");
                sceneData.CreateNewBakingSet("New Baking Set");
                UpdateSceneData();
                OnBakingSetSelected(list);
            };

            m_BakingSets.onRemoveCallback = (list) =>
            {
                if (m_BakingSets.count == 1)
                {
                    EditorUtility.DisplayDialog("Can't delete baking set", "You can't delete the last Baking set. You need to have at least one.", "Ok");
                    return;
                }
                if (EditorUtility.DisplayDialog("Delete the selected baking set?", $"Deleting the baking set will also delete it's profile asset on disk.\nDo you really want to delete the baking set '{sceneData.bakingSets[list.index].name}'?\n\nYou cannot undo the delete assets action.", "Yes", "Cancel"))
                {
                    var pathToDelete = AssetDatabase.GetAssetPath(sceneData.bakingSets[list.index].profile);
                    if (!String.IsNullOrEmpty(pathToDelete))
                    {
                        AssetDatabase.DeleteAsset(pathToDelete);
                    }
                    Undo.RegisterCompleteObjectUndo(sceneData.parentAsset, "Deleted baking set");
                    ReorderableList.defaultBehaviours.DoRemoveButton(list);
                    UpdateSceneData();
                    // A new set will be selected automatically, so we perform the same operations as if we did the selection explicitly.
                    OnBakingSetSelected(m_BakingSets);
                }
            };

            m_BakingSets.index = Mathf.Clamp(EditorPrefs.GetInt(k_SelectedBakingSetKey, 0), 0, m_BakingSets.count - 1);

            OnBakingSetSelected(m_BakingSets);
        }
Example #43
0
 private void InitializePredefinedVariablesList ()
 {
     predefinedVariablesList = new ReorderableList(SerializedObject, SerializedObject.FindProperty(nameof(CustomVariablesConfiguration.PredefinedVariables)), true, true, true, true);
     predefinedVariablesList.drawHeaderCallback = DrawPredefinedVariablesListHeader;
     predefinedVariablesList.drawElementCallback = DrawPredefinedVariablesListElement;
 }
        internal bool OnGUI(BuildTargetGroup buildTargetGroup)
        {
            PopulateDeprecationInfo();

            var settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);

            if (buildTargetGroup != CurrentBuildTargetGroup || m_LoaderMetadata == null)
            {
                CurrentBuildTargetGroup = buildTargetGroup;

                if (m_LoaderMetadata == null)
                {
                    m_LoaderMetadata = new List <LoaderInformation>();
                }
                else
                {
                    m_LoaderMetadata.Clear();
                }

                foreach (var pmd in XRPackageMetadataStore.GetLoadersForBuildTarget(buildTargetGroup))
                {
                    if (IsDeprecated(pmd.loaderName))
                    {
                        continue;
                    }

                    var newLi = new LoaderInformation()
                    {
                        packageName    = pmd.packageName,
                        packageId      = pmd.packageId,
                        loaderName     = pmd.loaderName,
                        loaderType     = pmd.loaderType,
                        toggled        = XRPackageMetadataStore.IsLoaderAssigned(pmd.loaderType, buildTargetGroup),
                        disabled       = false,
                        customLoaderUI = XRCustomLoaderUIManager.GetCustomLoaderUI(pmd.loaderType, buildTargetGroup)
                    };

                    if (newLi.customLoaderUI != null)
                    {
                        newLi.customLoaderUI.IsLoaderEnabled        = newLi.toggled;
                        newLi.customLoaderUI.ActiveBuildTargetGroup = CurrentBuildTargetGroup;
                    }
                    m_LoaderMetadata.Add(newLi);
                }

                if (settings != null)
                {
                    List <LoaderInformation> loadersWantingToDisableOtherLoaders = new List <LoaderInformation>();

                    LoaderInformation li;
                    for (int i = 0; i < m_LoaderMetadata.Count; i++)
                    {
                        li = m_LoaderMetadata[i];
                        if (XRPackageMetadataStore.IsLoaderAssigned(settings.AssignedSettings, li.loaderType))
                        {
                            li.toggled          = true;
                            m_LoaderMetadata[i] = li;

                            if (li.customLoaderUI != null)
                            {
                                loadersWantingToDisableOtherLoaders.Add(li);
                            }
                            break;
                        }
                    }

                    foreach (var loader in loadersWantingToDisableOtherLoaders)
                    {
                        SetDisablesStateOnLoadersFromLoader(loader);
                    }
                }

                m_OrderedList = new ReorderableList(m_LoaderMetadata, typeof(LoaderInformation), false, true, false, false);
                m_OrderedList.drawHeaderCallback = (rect) =>
                {
                    var labelSize = EditorStyles.label.CalcSize(Content.k_LoaderUITitle);
                    var labelRect = new Rect(rect);
                    labelRect.width = labelSize.x;

                    labelSize = EditorStyles.label.CalcSize(Content.k_HelpContent);
                    var imageRect = new Rect(rect);
                    imageRect.xMin  = labelRect.xMax + 1;
                    imageRect.width = labelSize.x;

                    EditorGUI.LabelField(labelRect, Content.k_LoaderUITitle, EditorStyles.label);
                    if (GUI.Button(imageRect, Content.k_HelpContent, EditorStyles.label))
                    {
                        System.Diagnostics.Process.Start(Content.k_HelpUri);
                    }
                };
                m_OrderedList.drawElementCallback           = (rect, index, isActive, isFocused) => DrawElementCallback(rect, index, isActive, isFocused);
                m_OrderedList.drawElementBackgroundCallback = (rect, index, isActive, isFocused) =>
                {
                    var tex = GUI.skin.label.normal.background;
                    if (tex == null && GUI.skin.label.normal.scaledBackgrounds.Length > 0)
                    {
                        tex = GUI.skin.label.normal.scaledBackgrounds[0];
                    }
                    if (tex == null)
                    {
                        return;
                    }

                    GUI.DrawTexture(rect, GUI.skin.label.normal.background);
                };
                m_OrderedList.drawFooterCallback = (rect) =>
                {
                    var status = XRPackageMetadataStore.GetCurrentStatusDisplayText();
                    GUI.Label(rect, EditorGUIUtility.TrTextContent(status), EditorStyles.label);
                };
                m_OrderedList.elementHeightCallback = (index) => GetElementHeight(index);
            }

            if (m_LoaderMetadata == null || m_LoaderMetadata.Count == 0)
            {
                EditorGUILayout.HelpBox(k_AtNoLoaderInstance, MessageType.Info);
            }
            else
            {
                m_OrderedList.DoLayoutList();
                if (settings != null)
                {
                    LoaderInformation li;
                    for (int i = 0; i < m_LoaderMetadata.Count; i++)
                    {
                        li = m_LoaderMetadata[i];
                        if (li.stateChanged && li.customLoaderUI != null)
                        {
                            SetDisablesStateOnLoadersFromLoader(li);
                        }
                    }

                    for (int i = 0; i < m_LoaderMetadata.Count; i++)
                    {
                        li = m_LoaderMetadata[i];
                        if (li.stateChanged)
                        {
                            if (li.toggled)
                            {
                                XRPackageMetadataStore.InstallPackageAndAssignLoaderForBuildTarget(li.packageId, li.loaderType, buildTargetGroup);
                            }
                            else
                            {
                                XRPackageMetadataStore.RemoveLoader(settings.AssignedSettings, li.loaderType, buildTargetGroup);
                            }
                            li.stateChanged     = false;
                            m_LoaderMetadata[i] = li;
                        }
                    }
                }
            }

            return(false);
        }
Example #45
0
 protected override void OnUpdateList(ReorderableList r)
 {
     r.list = Controller.getInstance().getSelectedChapterDataControl().getObjects <QR>().ConvertAll(qr => qr.Id);
 }
Example #46
0
 void rlOnAddCallback(ReorderableList _rl)
 {
     // Uncomment the below line to display message when Item is added.
     // Debug.Log("New item added");
 }
Example #47
0
 protected override void OnRemove(ReorderableList r)
 {
     Controller.getInstance().getSelectedChapterDataControl().getObjects <QR>().RemoveAt(r.index);
 }
 void OnRemoveGroupTemplateObject(ReorderableList list)
 {
     m_AasTarget.RemoveGroupTemplateObject(list.index);
 }
Example #49
0
 protected override void OnAddOption(ReorderableList r, string option)
 {
 }
        void DrawRendererListLayout(ReorderableList list, SerializedProperty prop)
        {
            list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                rect.y += 2;
                Rect indexRect = new Rect(rect.x, rect.y, 14, EditorGUIUtility.singleLineHeight);
                EditorGUI.LabelField(indexRect, index.ToString());
                Rect objRect = new Rect(rect.x + indexRect.width, rect.y, rect.width - 134, EditorGUIUtility.singleLineHeight);

                EditorGUI.BeginChangeCheck();
                EditorGUI.ObjectField(objRect, prop.GetArrayElementAtIndex(index), GUIContent.none);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(target);
                }

                Rect defaultButton   = new Rect(rect.width - 75, rect.y, 86, EditorGUIUtility.singleLineHeight);
                var  defaultRenderer = m_DefaultRendererProp.intValue;
                GUI.enabled = index != defaultRenderer;
                if (GUI.Button(defaultButton, !GUI.enabled ? Styles.rendererDefaultText : Styles.rendererSetDefaultText))
                {
                    m_DefaultRendererProp.intValue = index;
                    EditorUtility.SetDirty(target);
                }
                GUI.enabled = true;

                Rect selectRect = new Rect(rect.x + rect.width - 24, rect.y, 24, EditorGUIUtility.singleLineHeight);

                UniversalRenderPipelineAsset asset = target as UniversalRenderPipelineAsset;

                if (asset.ValidateRendererData(index))
                {
                    if (GUI.Button(selectRect, Styles.rendererSettingsText))
                    {
                        Selection.SetActiveObjectWithContext(prop.GetArrayElementAtIndex(index).objectReferenceValue,
                                                             null);
                    }
                }
                else // Missing ScriptableRendererData
                {
                    if (GUI.Button(selectRect, index == defaultRenderer ? Styles.rendererDefaultMissingText : Styles.rendererMissingText))
                    {
                        EditorGUIUtility.ShowObjectPicker <ScriptableRendererData>(null, false, null, index);
                    }
                }

                // If object selector chose an object, assign it to the correct ScriptableRendererData slot.
                if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == index)
                {
                    prop.GetArrayElementAtIndex(index).objectReferenceValue = EditorGUIUtility.GetObjectPickerObject();
                }
            };

            list.drawHeaderCallback = (Rect rect) =>
            {
                EditorGUI.LabelField(rect, Styles.rendererHeaderText);
            };

            list.onCanRemoveCallback = li => { return(li.count > 1); };

            list.onRemoveCallback = li =>
            {
                bool shouldUpdateIndex = false;
                // Checking so that the user is not deleting  the default renderer
                if (li.index != m_DefaultRendererProp.intValue)
                {
                    // Need to add the undo to the removal of our assets here, for it to work properly.
                    Undo.RecordObject(target, $"Deleting renderer at index {li.index}");

                    if (prop.GetArrayElementAtIndex(li.index).objectReferenceValue == null)
                    {
                        shouldUpdateIndex = true;
                    }
                    prop.DeleteArrayElementAtIndex(li.index);
                }
                else
                {
                    EditorUtility.DisplayDialog(Styles.rendererListDefaultMessage.text, Styles.rendererListDefaultMessage.tooltip,
                                                "Close");
                }

                if (shouldUpdateIndex)
                {
                    UpdateDefaultRendererValue(li.index);
                }

                EditorUtility.SetDirty(target);
            };

            list.onReorderCallbackWithDetails += (reorderableList, index, newIndex) =>
            {
                // Need to update the default renderer index
                UpdateDefaultRendererValue(index, newIndex);
            };
        }
Example #51
0
 public void SetReorderableList(ReorderableList reorderableList)
 {
     this.reorderableList = reorderableList;
 }
        /// <summary>
        /// Draws inspector for a Slide Deck.
        /// </summary>
        /// <param name="deck">Slide Deck to draw.</param>
        /// <param name="scroll">Current vertical scroll value.</param>
        /// <param name="shouldSelect">A function which returns if the current slide should be selected.</param>
        /// <param name="onPlayPress">A function called when "Play" button of a slide is pressed.</param>
        /// <returns>Current vertical scroll value.</returns>
        public static float DrawInspector(SlideDeck deck, float scroll, Func <SlideDeck, int, bool> shouldSelect = null, Action <SlideDeck, int> onPlayPress = null)
        {
            if (styles == null)
            {
                styles = new Styles();
            }

            ReorderableList list;
            var             key = deck.GetInstanceID() + "#" + (shouldSelect != null) + "#" + (onPlayPress != null);

            if (!lists.TryGetValue(key, out list))
            {
                // Init a ReorderableList for the deck and cache it.
                list = new ReorderableList(deck.Slides, typeof(PresentationSlide), true, true, true, true);
                lists.Add(key, list);

                list.onChangedCallback += (l) =>
                {
//					deck.Save();
                };

                list.drawHeaderCallback += (Rect rect) => GUI.Label(rect, deck.IsSavedOnDisk ? deck.Name + ".asset" : "<not saved>");

                list.elementHeightCallback += (int index) => styles.ELEMENT_HEIGHT;

                list.drawElementBackgroundCallback += (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        if (index < 0)
                        {
                            return;
                        }

                        var bgcolor = GUI.backgroundColor;
                        var slide   = deck.Slides[index];

                        if (shouldSelect != null && shouldSelect(deck, index))
                        {
                            GUI.backgroundColor = styles.SELECTED_COLOR;
                            rect.height        += 3;
                            styles.BG_SELECTED.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        else
                        if (slide.Visible || isFocused)
                        {
                            styles.BG.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        else
                        {
                            GUI.backgroundColor = styles.INVISIBLE_COLOR;
                            rect.height        += 3;
                            styles.BG_INVISIBLE.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        GUI.backgroundColor = bgcolor;
                    }
                };

                list.drawElementCallback += (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    var changed = false;
                    var color   = GUI.color;
                    var slide   = deck.Slides[index];

                    // visible
                    EditorGUI.BeginChangeCheck();
                    if (!slide.Visible)
                    {
                        GUI.color = styles.INACTIVE_COLOR;
                    }
                    var newVisible = GUI.Toggle(
                        new Rect(rect.x, rect.y, styles.ICON.fixedWidth, rect.height), slide.Visible, styles.VISIBLE_ICON, styles.ICON);
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.Visible = newVisible;
                        changed       = true;
                    }
                    GUI.color = color;
                    rect.x   += styles.ICON.fixedWidth;

                    // play mode
                    EditorGUI.BeginChangeCheck();
                    if (!slide.StartInPlayMode)
                    {
                        GUI.color = styles.INACTIVE_COLOR;
                    }
                    var newPlaymode = GUI.Toggle(
                        new Rect(rect.x, rect.y, styles.ICON.fixedWidth, rect.height), slide.StartInPlayMode, styles.PLAYMODE_ICON, styles.ICON);
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.StartInPlayMode = newPlaymode;
                        changed = true;
                    }
                    GUI.color = color;
                    rect.x   += styles.ICON.fixedWidth;

                    // scene
                    var w = rect.width - styles.ICON.fixedWidth * 2;
                    if (onPlayPress != null)
                    {
                        w -= styles.PLAY_BUTTON.fixedWidth + 6;
                    }
                    var scene = AssetDatabase.LoadAssetAtPath <SceneAsset>(slide.ScenePath);
                    EditorGUI.BeginChangeCheck();
                    var newScene = EditorGUI.ObjectField(new Rect(rect.x, rect.y + 2, w, rect.height - 4), scene, typeof(SceneAsset), false) as SceneAsset;
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.Scene = newScene;
                        changed     = true;
                    }
                    rect.x += w + 6;

                    if (onPlayPress != null)
                    {
                        rect.y += 2;
                        if (GUI.Button(rect, styles.PLAY_ICON, styles.PLAY_BUTTON))
                        {
                            onPlayPress(deck, index);
                        }
                    }

                    if (changed)
                    {
                        deck.Save();
                    }
                };
            }

            scroll = EditorGUILayout.BeginScrollView(new Vector2(0, scroll), false, false, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)).y;
            var r = GUILayoutUtility.GetRect(0, list.GetHeight() + 20);

            list.DoList(r);

            var propsName   = "presentation_" + deck.name + "_options";
            var showOptions = EditorPrefs.GetBool(propsName, false);

            showOptions = GUIElements.Header(styles.TEXT_OPTIONS, showOptions);
            if (showOptions)
            {
                EditorGUI.indentLevel++;
                deck.BackgroundColor = EditorGUILayout.ColorField(styles.TEXT_BG_COLOR, deck.BackgroundColor, true, false, false, new ColorPickerHDRConfig(0, 1, 0, 1), GUILayout.ExpandWidth(true));
                EditorGUI.indentLevel--;
            }
            EditorPrefs.SetBool(propsName, showOptions);
            EditorGUILayout.EndScrollView();

            return(scroll);
        }
Example #53
0
 void rlOnAddDropdownCallback(Rect myRect, ReorderableList _rl)
 {
     dropDownMenu.DropDown(myRect);
 }
Example #54
0
 void rlSelectCallback(ReorderableList _rl)
 {
     // Uncomment the below line to display message when Item is selected.
     // Debug.Log("Item #" + _rl.index.ToString() + " selected.");
 }
 void OnRemoveDataBuilder(ReorderableList list)
 {
     m_AasTarget.RemoveDataBuilder(list.index);
 }
Example #56
0
    /// <summary>
    /// Creates a reorderable list for the encyclopedia entry text list.
    /// </summary>
    /// <param name="property">Encyclopedia entry text list from the encyclopedia entry.</param>
    /// <param name="label">Label for the reorderable list.</param>
    /// <returns>Reorderable list of encyclopedia entry text objects.</returns>
    private ReorderableList CreateEntryTextList(SerializedProperty property, string label)
    {
        // Create a new reorderable list for the property, and display all options
        ReorderableList list = new ReorderableList(property.serializedObject, property, true, true, true, true)
        {
            // Allow the reorderable list to be collapsed
            drawHeaderCallback = (Rect rect) =>
            {
                Rect newRect = new Rect(rect.x + 10, rect.y, rect.width - 10, rect.height);
                property.isExpanded = EditorGUI.Foldout(newRect, property.isExpanded, label);
            },

            // If the list is collapsed, disable it. If not, display each element's property drawer
            drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                if (!property.isExpanded)
                {
                    GUI.enabled = index == property.arraySize;
                    return;
                }

                SerializedProperty element = property.GetArrayElementAtIndex(index);

                EditorGUI.PropertyField(rect, element, true);
            },

            // Return 0 for all element heights if the list is collapsed, else return the element height plus line spacing
            elementHeightCallback = (int index) =>
            {
                if (!property.isExpanded)
                {
                    return(0);
                }

                SerializedProperty element = property.GetArrayElementAtIndex(index);

                float height = EditorGUI.GetPropertyHeight(element, true);

                return(height + lineHeightSpacing);
            },

            // Set all values to default when adding a new element, instead of copying the previous value
            onAddCallback = (ReorderableList l) =>
            {
                // Increase the list's size and get the index for the new element
                int index = l.serializedProperty.arraySize;
                l.serializedProperty.arraySize++;
                l.index = index;

                // Set all of the new element's values to default
                SerializedProperty element = l.serializedProperty.GetArrayElementAtIndex(index);
                element.FindPropertyRelative(EncyclopediaEntryTextMembers.Name).stringValue = string.Empty;
                element.FindPropertyRelative(EncyclopediaEntryTextMembers.EntryText).objectReferenceValue = null;
                element.FindPropertyRelative(EncyclopediaEntryTextMembers.UnlockPath).FindPropertyRelative(ProgressPathMembers.ChapterNum).intValue = 0;
                element.FindPropertyRelative(EncyclopediaEntryTextMembers.UnlockPath).FindPropertyRelative(ProgressPathMembers.SectionNum).intValue = 0;
            },

            // Display a warning message before removing values from the list
            onRemoveCallback = (ReorderableList l) =>
            {
                if (EditorUtility.DisplayDialog("Remove Item Warning", "Are you sure you want to delete this item?", "Yes", "No"))
                {
                    ReorderableList.defaultBehaviours.DoRemoveButton(l);
                }
            },

            // Draw the element backgrounds in alternating colors for better readability
            drawElementBackgroundCallback = (Rect rect, int index, bool active, bool focused) =>
            {
                if (index % 2 == 0)
                {
                    Texture2D tex = new Texture2D(1, 1);
                    tex.SetPixel(0, 0, new Color(.1f, .33f, 1f, .10f));
                    tex.Apply();
                    GUI.DrawTexture(rect, tex as Texture);
                }
                else
                {
                    Texture2D tex = new Texture2D(1, 1);
                    tex.SetPixel(0, 0, new Color(.1f, .33f, 1f, .33f));
                    tex.Apply();
                    GUI.DrawTexture(rect, tex as Texture);
                }
            }
        };

        return(list);
    }
        void OnEnable()
        {
            m_GeneralSettingsFoldout        = new SavedBool($"{target.GetType()}.GeneralSettingsFoldout", false);
            m_QualitySettingsFoldout        = new SavedBool($"{target.GetType()}.QualitySettingsFoldout", false);
            m_LightingSettingsFoldout       = new SavedBool($"{target.GetType()}.LightingSettingsFoldout", false);
            m_ShadowSettingsFoldout         = new SavedBool($"{target.GetType()}.ShadowSettingsFoldout", false);
            m_PostProcessingSettingsFoldout = new SavedBool($"{target.GetType()}.PostProcessingSettingsFoldout", false);
            m_AdvancedSettingsFoldout       = new SavedBool($"{target.GetType()}.AdvancedSettingsFoldout", false);
            m_AdaptivePerformanceFoldout    = new SavedBool($"{target.GetType()}.AdaptivePerformanceFoldout", false);

            m_RendererDataProp    = serializedObject.FindProperty("m_RendererDataList");
            m_DefaultRendererProp = serializedObject.FindProperty("m_DefaultRendererIndex");
            m_RendererDataList    = new ReorderableList(serializedObject, m_RendererDataProp, true, true, true, true);

            DrawRendererListLayout(m_RendererDataList, m_RendererDataProp);

            m_RequireDepthTextureProp  = serializedObject.FindProperty("m_RequireDepthTexture");
            m_RequireOpaqueTextureProp = serializedObject.FindProperty("m_RequireOpaqueTexture");
            m_OpaqueDownsamplingProp   = serializedObject.FindProperty("m_OpaqueDownsampling");
            m_SupportsTerrainHolesProp = serializedObject.FindProperty("m_SupportsTerrainHoles");

            m_HDR         = serializedObject.FindProperty("m_SupportsHDR");
            m_MSAA        = serializedObject.FindProperty("m_MSAA");
            m_RenderScale = serializedObject.FindProperty("m_RenderScale");

            m_MainLightRenderingModeProp       = serializedObject.FindProperty("m_MainLightRenderingMode");
            m_MainLightShadowsSupportedProp    = serializedObject.FindProperty("m_MainLightShadowsSupported");
            m_MainLightShadowmapResolutionProp = serializedObject.FindProperty("m_MainLightShadowmapResolution");

            m_AdditionalLightsRenderingModeProp      = serializedObject.FindProperty("m_AdditionalLightsRenderingMode");
            m_AdditionalLightsPerObjectLimitProp     = serializedObject.FindProperty("m_AdditionalLightsPerObjectLimit");
            m_AdditionalLightShadowsSupportedProp    = serializedObject.FindProperty("m_AdditionalLightShadowsSupported");
            m_AdditionalLightShadowmapResolutionProp = serializedObject.FindProperty("m_AdditionalLightsShadowmapResolution");

            m_AdditionalLightsShadowResolutionTierLowProp    = serializedObject.FindProperty("m_AdditionalLightsShadowResolutionTierLow");
            m_AdditionalLightsShadowResolutionTierMediumProp = serializedObject.FindProperty("m_AdditionalLightsShadowResolutionTierMedium");
            m_AdditionalLightsShadowResolutionTierHighProp   = serializedObject.FindProperty("m_AdditionalLightsShadowResolutionTierHigh");

            m_ShadowDistanceProp = serializedObject.FindProperty("m_ShadowDistance");

            m_ShadowCascadeCountProp   = serializedObject.FindProperty("m_ShadowCascadeCount");
            m_ShadowCascade2SplitProp  = serializedObject.FindProperty("m_Cascade2Split");
            m_ShadowCascade3SplitProp  = serializedObject.FindProperty("m_Cascade3Split");
            m_ShadowCascade4SplitProp  = serializedObject.FindProperty("m_Cascade4Split");
            m_ShadowCascadeBorderProp  = serializedObject.FindProperty("m_CascadeBorder");
            m_ShadowDepthBiasProp      = serializedObject.FindProperty("m_ShadowDepthBias");
            m_ShadowNormalBiasProp     = serializedObject.FindProperty("m_ShadowNormalBias");
            m_SoftShadowsSupportedProp = serializedObject.FindProperty("m_SoftShadowsSupported");

            m_SRPBatcher = serializedObject.FindProperty("m_UseSRPBatcher");
            m_SupportsDynamicBatching    = serializedObject.FindProperty("m_SupportsDynamicBatching");
            m_MixedLightingSupportedProp = serializedObject.FindProperty("m_MixedLightingSupported");
            m_DebugLevelProp             = serializedObject.FindProperty("m_DebugLevel");

            m_ShaderVariantLogLevel = serializedObject.FindProperty("m_ShaderVariantLogLevel");

            m_ColorGradingMode    = serializedObject.FindProperty("m_ColorGradingMode");
            m_ColorGradingLutSize = serializedObject.FindProperty("m_ColorGradingLutSize");

            m_UseFastSRGBLinearConversion = serializedObject.FindProperty("m_UseFastSRGBLinearConversion");

            m_UseAdaptivePerformance = serializedObject.FindProperty("m_UseAdaptivePerformance");

            string Key = "Universal_Shadow_Setting_Unit:UI_State";

            m_State = new EditorPrefBoolFlags <EditorUtils.Unit>(Key);
        }
Example #58
0
        public override void OnEnable()
        {
            base.OnEnable();

            item = (ItemCollectionBase)target;
            //serializer = new SerializedObject(target);
            serializer = serializedObject;

            collectionName    = serializer.FindProperty("collectionName");
            restrictByWeight  = serializer.FindProperty("restrictByWeight");
            restrictMaxWeight = serializer.FindProperty("restrictMaxWeight");
            itemButtonPrefab  = serializer.FindProperty("itemButtonPrefab");

            items                     = serializer.FindProperty("_items");
            useReferences             = serializer.FindProperty("useReferences");
            canDropFromCollection     = serializer.FindProperty("canDropFromCollection");
            canUseFromCollection      = serializer.FindProperty("canUseFromCollection");
            canDragInCollection       = serializer.FindProperty("canDragInCollection");
            canPutItemsInCollection   = serializer.FindProperty("canPutItemsInCollection");
            canStackItemsInCollection = serializer.FindProperty("canStackItemsInCollection");
            manuallyDefineCollection  = serializer.FindProperty("manuallyDefineCollection");
            container                 = serializer.FindProperty("container");
            onlyAllowTypes            = serializer.FindProperty("_onlyAllowTypes");

            itemManager = Editor.FindObjectOfType <ItemManager>();
            if (itemManager == null)
            {
                Debug.LogError("No item manager found in scene, cannot edit item.");
            }


            manualItemsList = new ReorderableList(serializer, items, true, true, true, true);
            manualItemsList.drawHeaderCallback += rect =>
            {
                EditorGUI.LabelField(rect, "Select items");
            };
            manualItemsList.drawElementCallback += (rect, index, active, focused) =>
            {
                rect.height = 16;
                rect.y     += 2;

                EditorGUI.PropertyField(rect, items.GetArrayElementAtIndex(index));
            };

            onlyAllowTypesList = new ReorderableList(serializer, onlyAllowTypes, false, true, true, true);
            onlyAllowTypesList.drawHeaderCallback += rect =>
            {
                EditorGUI.LabelField(rect, "Restrict by type, leave empty to allow all types");
            };
            onlyAllowTypesList.drawElementCallback += (rect, index, active, focused) =>
            {
                rect.height = 16;
                rect.y     += 2;

                var r = rect;
                r.width -= 60;

                EditorGUI.LabelField(r, (item.onlyAllowTypes[index] != null) ? item.onlyAllowTypes[index].FullName : "(NOT SET)");

                var r2 = rect;
                r2.width  = 60;
                r2.height = 14;
                r2.x     += r.width;
                if (GUI.Button(r2, "Set"))
                {
                    var typePicker = InventoryItemTypePicker.Get();
                    typePicker.Show(InventoryEditorUtil.GetItemDatabase(true, false));
                    typePicker.OnPickObject += type =>
                    {
                        item._onlyAllowTypes[index] = type.AssemblyQualifiedName;
                        GUI.changed = true; // To save..
                        EditorUtility.SetDirty(target);
                        serializer.ApplyModifiedProperties();
                        Repaint();
                    };
                }
            };
        }
 void OnAddDropdownCallback(Rect buttonRect, ReorderableList list)
 {
     RefreshAddList();
     m_AddingMenu.DropDown(buttonRect);
 }
 private void OnClickAddBtn(ReorderableList targetList)
 {
     _editor.model.symbols.Add(new DefineSymbol("NEW_SYMBOL", false, true));
 }