コード例 #1
0
        static void DrawKeySelect(Rect pos, SerializedProperty prop)
        {
            if (prop.stringValue.EndsWith("@"))
            {
                return;
            }



            EditorGUI.LabelField(new Rect(pos.x, pos.y, EditorGUIUtility.labelWidth, pos.height), new GUIContent(prop.displayName));
            if (GUITools.Button(pos.x + EditorGUIUtility.labelWidth, pos.y, pos.width - (EditorGUIUtility.labelWidth + GUITools.iconButtonWidth), pos.height, new GUIContent(!string.IsNullOrEmpty(prop.stringValue) ? prop.stringValue : "[ Null ]"), GUITools.popup))
            {
                List <string> allKeys = LocationAliases.GetAliasList();
                if (!allKeys.Contains(prop.stringValue))
                {
                    prop.stringValue = string.Empty;
                }

                GenericMenu menu = new GenericMenu();

                for (int i = 0; i < allKeys.Count; i++)
                {
                    string e = allKeys[i];
                    menu.AddItem(new GUIContent(e), e == prop.stringValue,
                                 () => {
                        prop.stringValue = e;
                        prop.serializedObject.ApplyModifiedProperties();
                    }
                                 );
                }
                menu.ShowAsContext();
            }
        }
コード例 #2
0
        public LocationInfo GetLocationByIdentifier(string locationIdentifier)
        {
            var locationInfo = LocationCache.SingleOrDefault(l => l.LocationIdentifier.Equals(locationIdentifier, StringComparison.InvariantCultureIgnoreCase));

            if (locationInfo != null)
            {
                return(locationInfo);
            }

            if (LocationAliases.TryGetValue(locationIdentifier, out var aliasedIdentifier))
            {
                locationInfo = LocationCache.SingleOrDefault(l => l.LocationIdentifier.Equals(aliasedIdentifier, StringComparison.InvariantCultureIgnoreCase));

                if (locationInfo != null)
                {
                    return(locationInfo);
                }

                locationIdentifier = aliasedIdentifier;
            }

            var locationDescriptions = Client.Publish.Get(new LocationDescriptionListServiceRequest
            {
                LocationIdentifier = locationIdentifier
            })
                                       .LocationDescriptions;

            var locationDescription = locationDescriptions
                                      .FirstOrDefault(l => l.Identifier == locationIdentifier);

            if (locationDescription == null)
            {
                var closeMatches = locationDescriptions
                                   .Where(l => l.Identifier.Equals(locationIdentifier, StringComparison.InvariantCultureIgnoreCase))
                                   .ToList();

                if (closeMatches.Count == 1)
                {
                    locationDescription = closeMatches.Single();
                }
            }

            if (locationDescription == null)
            {
                Log.Error(!locationDescriptions.Any()
                    ? $"Location '{locationIdentifier}' does not exist."
                    : $"Location '{locationIdentifier}' has ambiguously found {locationDescriptions.Count} matches: {string.Join(", ", locationDescriptions.Select(l => l.Identifier))}");

                return(AddUnknownLocationInfo(locationIdentifier));
            }

            var location = Client.Provisioning.Get(new GetLocation {
                LocationUniqueId = locationDescription.UniqueId
            });

            return(AddLocationInfo(location));
        }
コード例 #3
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            SerializedProperty useAlias = prop.FindPropertyRelative("useAlias");

            GUITools.Box(new Rect(pos.x, pos.y, pos.width, CalcHeight(useAlias)), new Color32(0, 0, 0, 32));

            pos.height = GUITools.singleLineHeight;
            GUITools.Label(pos, label, GUITools.black, GUITools.boldLabel);

            GUITools.DrawIconToggle(useAlias, new GUIContent("A", "Use Alias"), pos.x + (pos.width - GUITools.iconButtonWidth), pos.y);


            pos.y += GUITools.singleLineHeight;

            if (useAlias.boolValue)
            {
                SerializedProperty aliasProp = prop.FindPropertyRelative("alias");
                DrawKeySelect(pos, aliasProp);

                GUI.enabled = !string.IsNullOrEmpty(aliasProp.stringValue);

                if (GUITools.IconButton(pos.x + (pos.width - GUITools.iconButtonWidth), pos.y, new GUIContent("G", "Go To Scene / Location"), GUITools.white))
                {
                    LocationKey key = LocationAliases.GetLocationKey(aliasProp.stringValue);
                    if (key != null)
                    {
                        LocationKeyDrawer.FastTravelToLocation(key.scene, key.name);
                    }
                }
                GUI.enabled = true;
            }
            else
            {
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("key"), true);
            }
        }
コード例 #4
0
 public static void MoveObject(string key, string alias)
 {
     MoveObject(key, LocationAliases.GetLocationKey(alias));
 }
コード例 #5
0
 public static void MovePlayer(string alias, bool forceReload)
 {
     MovePlayer(LocationAliases.GetLocationKey(alias), forceReload);
 }
コード例 #6
0
 public LocationKey GetKey()
 {
     return(useAlias ? LocationAliases.GetLocationKey(alias) : key);
 }