예제 #1
0
        private static void TryResolveTargetGate(Scene a, Scene b)
        {
            if (!_hasTarget)
            {
                GatewaysEvents.OnTargetMissing();
                return;
            }

            GameObject gameObject = GuidManager.ResolveGuid(_target);

            if (gameObject == null)
            {
                GatewaysEvents.OnGateUnresolved();
                return;
            }

            GateBase gate = gameObject.GetComponent <GateBase>();

            if (gate == null)
            {
                GatewaysEvents.OnGateComponentNotFound();
                return;
            }

            _hasTarget = false;
            _target    = Guid.Empty;

            gate.OnGateResolved();
        }
예제 #2
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, GateBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_ParseToSeason, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Server.Protos.UserInfo, global::Server.Protos.Reply>(serviceImpl.ParseToSeason));
 }
예제 #3
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(GateBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_ParseToSeason, serviceImpl.ParseToSeason).Build());
 }
예제 #4
0
 public static void WriteTargetGate(GateBase gate)
 {
     WriteTargetGate(gate.GetGuid());
 }
예제 #5
0
 public static void WritePreviousGate(GateBase gate)
 {
     WritePreviousGate(gate.GetGuid());
 }
예제 #6
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            _guidProp         = property.FindPropertyRelative("_serializedGuid");
            _nameProp         = property.FindPropertyRelative("_cachedName");
            _sceneProp        = property.FindPropertyRelative("_cachedScene");
            _lockedReference  = property.FindPropertyRelative("_sceneReference");
            _sceneRefInstance = _lockedReference.FindPropertyRelative("_instance");

            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            EditorGUI.BeginProperty(position, label, property);

            // Draw prefix label, returning the new rect we can draw in
            var guidCompPosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            guidCompPosition.height = EditorGUIUtility.singleLineHeight;

            System.Guid currentGuid;
            GameObject  currentGO = null;

            // working with array properties is a bit unwieldy
            // you have to get the property at each index manually
            byte[] byteArray = new byte[16];
            int    arraySize = _guidProp.arraySize;

            for (int i = 0; i < arraySize; ++i)
            {
                var byteProp = _guidProp.GetArrayElementAtIndex(i);
                byteArray[i] = (byte)byteProp.intValue;
            }

            currentGuid = new System.Guid(byteArray);
            currentGO   = GuidManager.ResolveGuid(currentGuid);
            GateBase currentGate = currentGO != null?currentGO.GetComponent <GateBase>() : null;

            GateBase component = null;

            if (currentGuid != System.Guid.Empty && currentGate == null)
            {
                // if our reference is set, but the target isn't loaded, we display the target and the scene it is in, and provide a way to clear the reference
                Rect buttonRect;
                Rect newPosition = IMGUIUtils.SnipRectH(guidCompPosition, guidCompPosition.width - 70, out buttonRect, 6f);

                bool guiEnabled = GUI.enabled;
                GUI.enabled = false;
                EditorGUI.LabelField(newPosition, new GUIContent(_nameProp.stringValue, "Target GameObject is not currently loaded."), EditorStyles.objectField);
                GUI.enabled = guiEnabled;

                if (GUI.Button(buttonRect, _clearButtonGUI, EditorStyles.miniButton))
                {
                    ClearPreviousGuid();
                }
            }
            else
            {
                // if our object is loaded, we can simply use an object field directly
                component = EditorGUI.ObjectField(guidCompPosition, currentGate, typeof(GateBase), true) as GateBase;
            }

            if (currentGate != null && component == null)
            {
                // clear out an old Guid after the user has changed/removed a reference in inspector
                ClearPreviousGuid();
            }

            // if we have a valid reference, draw the scene name of the scene it lives in so users can find it
            if (component != null)
            {
                _nameProp.stringValue = component.name;
                string     scenePath  = component.gameObject.scene.path;
                SceneAsset sceneAsset = AssetDatabase.LoadAssetAtPath <SceneAsset>(scenePath);
                _sceneProp.objectReferenceValue = sceneAsset;

                Scene scene = EditorSceneManager.GetSceneByName(((SceneAsset)_sceneProp.objectReferenceValue).name);

                _sceneRefInstance.FindPropertyRelative("_sceneAsset").objectReferenceValue = sceneAsset;
                _sceneRefInstance.FindPropertyRelative("_sceneName").stringValue           = scene.name;
                _sceneRefInstance.FindPropertyRelative("_scenePath").stringValue           = scene.path;
                _sceneRefInstance.FindPropertyRelative("_buildIndex").intValue             = scene.buildIndex;

                // only update the GUID Prop if something changed. This fixes multi-edit on GUID References
                if (component != currentGate)
                {
                    byteArray = component.GetGuid().ToByteArray();
                    arraySize = _guidProp.arraySize;
                    for (int i = 0; i < arraySize; ++i)
                    {
                        var byteProp = _guidProp.GetArrayElementAtIndex(i);
                        byteProp.intValue = byteArray[i];
                    }
                }
            }

            position.y += EditorGUIUtility.singleLineHeight + 2;
            Rect sceneFieldPosition = new Rect(position);

            sceneFieldPosition.height = EditorGUI.GetPropertyHeight(_lockedReference, true);

            EditorGUI.PropertyField(sceneFieldPosition, _lockedReference, true);

            EditorGUI.EndProperty();
        }