Esempio n. 1
0
    /// <summary>
    /// Draws a custom drawing.
    /// </summary>
    /// <param name="drawing">A custom drawing to draw.</param>
    /// <returns>The fluent object to add parameters.</returns>
    public static Drawing Draw(Drawing drawing)
    {
#if UNITY_EDITOR
        GizmoDrawer.Draw(drawing);
#endif
        return(drawing);
    }
Esempio n. 2
0
 private void OnDrawGizmos()
 {
     if (collider != null)
     {
         GizmoDrawer.Draw(collider, GizmoColor);
     }
 }
Esempio n. 3
0
    // Start is called before the first frame update
    void Start()
    {
        GizmoDrawer gd = GetComponent <GizmoDrawer>();

        gd.radius       = range;
        gd.showGizmo    = true;
        dividedFireRate = 1.0f / fireRate;

        //muzzleflash.Stop();
    }
        public void Draw(Vector3 pos, Quaternion?rotation = null)
        {
            rotation ??= Quaternion.identity;

            if (GizmoMesh)
            {
                GizmoDrawer.Draw(GizmoMesh, Color, pos, rotation.Value, Vector3.one * 0.1f);
                return;
            }

            GizmoDrawer.DrawSphere(pos, 0.05f, Color);
        }
Esempio n. 5
0
    /// <summary>
    /// Draws a custom drawing.
    /// </summary>
    /// <param name="drawing">A custom drawing to draw.</param>
    /// <returns>The fluent object to add parameters.</returns>
    public static Drawing Draw(Drawing drawing)
    {
#if UNITY_EDITOR
        GizmoDrawer.Draw(drawing);
#else
        if (DebugPlusManager.I.enableInBuild)
        {
            GizmoDrawer.Draw(drawing);
        }
#endif
        return(drawing);
    }
Esempio n. 6
0
    void OnEnable()
    {
        Giz = Camera.main.GetComponent <GizmoDrawer>();
        if (EditorPrefs.HasKey("ObjectPath"))
        {
            string objectPath = EditorPrefs.GetString("ObjectPath");
            sceneScript = AssetDatabase.LoadAssetAtPath(objectPath, typeof(SceneScript)) as SceneScript;
        }

        SceneScript obj = ScriptableObject.CreateInstance <SceneScript>();

        serializedObject = new UnityEditor.SerializedObject(obj);
    }
Esempio n. 7
0
    public override void OnInspectorGUI()
    {
        GizmoDrawer obj = serializedObject.targetObject as GizmoDrawer;

        if (obj == null)
        {
            return;
        }
        obj.color = EditorGUILayout.ColorField(obj.color);
        if (GUILayout.Button("Refresh"))
        {
            obj.ClearCache();
        }
    }
        internal RuntimeUnityEditorCore(MonoBehaviour pluginObject, ILoggerWrapper logger, string configPath)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Can only create one instance of the Core object");
            }

            CompositeResolver.RegisterAndSetAsDefault(GeneratedResolver.Instance, BuiltinResolver.Instance, PrimitiveObjectResolver.Instance);

            PluginObject = pluginObject;
            Logger       = logger;
            Instance     = this;

            InitNativeGUI();

            Inspector = new Inspector.Inspector(targetTransform => TreeViewer.SelectAndShowObject(targetTransform));

            TreeViewer = new ObjectTreeViewer(pluginObject);
            TreeViewer.InspectorOpenCallback = items =>
            {
                Inspector.InspectorClear();
                foreach (var stackEntry in items)
                {
                    Inspector.InspectorPush(stackEntry);
                }
            };

            if (UnityFeatureHelper.SupportsVectrosity)
            {
                GizmoDrawer = new GizmoDrawer(pluginObject);
                TreeViewer.TreeSelectionChangedCallback = transform => GizmoDrawer.UpdateState(transform);
            }

            if (UnityFeatureHelper.SupportsCursorIndex &&
                UnityFeatureHelper.SupportsXml)
            {
                try
                {
                    Repl = new ReplWindow(Path.Combine(configPath, "RuntimeUnityEditor.Autostart.cs"));
                    Repl.RunAutostart();
                }
                catch (Exception ex)
                {
                    Logger.Log(LogLevel.Warning, "Failed to load REPL - " + ex.Message);
                }
            }
        }
Esempio n. 9
0
        public void Setup(ILoggerWrapper logger)
        {
            INSTANCE = this;
            LOGGER   = logger;

            SettingsData = SettingsManager.LoadOrCreate();
            DnSpyHelper.SetPath(SettingsData.DNSpyPath, false);

            SettingsViewer = new SettingsViewer();
            TreeViewer     = new ObjectTreeViewer(this, _gameObjectSearcher)
            {
                InspectorOpenCallback = items =>
                {
                    Inspector.InspectorClear();
                    foreach (var stackEntry in items)
                    {
                        Inspector.InspectorPush(stackEntry);
                    }
                }
            };

            _gizmoDrawer = new GizmoDrawer(this);
            TreeViewer.TreeSelectionChangedCallback = transform => _gizmoDrawer.UpdateState(transform);
            RegisterWindow(TreeViewer);

            if (UnityFeatureHelper.SupportsCursorIndex && UnityFeatureHelper.SupportsXml)
            {
                try
                {
                    Repl = new ReplWindow("RuntimeUnityEditor.Autostart.cs");
                    Repl.RunAutostart();
                    windows.Add(Repl);
                }
                catch (Exception ex)
                {
                    LOGGER.Log(LogLevel.Warning, "Failed to load REPL - " + ex.Message);
                }
            }

            Inspector = new Inspector.Inspector(targetTransform => TreeViewer.SelectAndShowObject(targetTransform), Repl);
            RegisterWindow(Inspector);

            PinnedVariablesData   = new PinnedVariablesData();
            PinnedVariablesViewer = new PinnedVariablesViewer(PinnedVariablesData);
            RegisterWindow(PinnedVariablesViewer);
        }
Esempio n. 10
0
        static void DrawOrDefer(Action drawAction)
        {
#if UNITY_EDITOR
            if (CanDrawGizmos())
            {
                drawAction();
            }
            else if (_canDeferGizmos)
            {
                if (_gizmoDrawer == null)
                {
                    _gizmoDrawer = new GameObject("Debug Gizmo Drawer").AddComponent <GizmoDrawer>();
                }

                _drawActions.Add(drawAction);
            }
#endif
        }
Esempio n. 11
0
        public RuntimeUnityEditorCore(MonoBehaviour pluginObject, ILoggerWrapper logger)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Can only create one instance of the Core object");
            }

            PluginObject = pluginObject;
            Logger       = logger;
            Instance     = this;

            Inspector = new Inspector.Inspector(targetTransform => TreeViewer.SelectAndShowObject(targetTransform));

            TreeViewer = new ObjectTreeViewer(pluginObject);
            TreeViewer.InspectorOpenCallback = items =>
            {
                Inspector.InspectorClear();
                foreach (var stackEntry in items)
                {
                    Inspector.InspectorPush(stackEntry);
                }
            };

            if (Utils.UnityFeatureHelper.SupportsVectrosity)
            {
                GizmoDrawer = new GizmoDrawer(pluginObject);
                TreeViewer.TreeSelectionChangedCallback = transform => GizmoDrawer.UpdateState(transform);
            }

            if (Utils.UnityFeatureHelper.SupportsCursorIndex &&
                Utils.UnityFeatureHelper.SupportsXml)
            {
                try
                {
                    Repl = new ReplWindow();
                }
                catch (Exception ex)
                {
                    Logger.Log(LogLevel.Warning, "Failed to load REPL - " + ex.Message);
                }
            }
        }
Esempio n. 12
0
 public static Drawing Draw(Drawing drawing)
 {
     GizmoDrawer.Draw(drawing);
     return(drawing);
 }
Esempio n. 13
0
 private void OnDrawGizmos()
 {
     GizmoDrawer.Draw(transform, Color.cyan, GizmoType.Box);
 }
Esempio n. 14
0
    void OnGUI()
    {
        EditorGUI.BeginChangeCheck();

        speechbuble          = GUI.skin.textArea;
        speechbuble.wordWrap = true;

        GUILayout.BeginHorizontal();
        GUILayout.Label("Scene Script Editor", EditorStyles.boldLabel);
        if (sceneScript != null)
        {
            //Basically show us the assets in the inspector ?
            if (GUILayout.Button("Show Item List"))
            {
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = sceneScript;
            }
        }
        if (GUILayout.Button("Open Item List"))
        {
            OpenItemList();
        }/*
          * if (GUILayout.Button("New Item List"))
          * {
          * EditorUtility.FocusProjectWindow();
          * Selection.activeObject = sceneScript;
          * }*/
        GUILayout.EndHorizontal();

        if (sceneScript != null)
        {
            GUILayout.Space(20);
            GUILayout.Label("Setup", EditorStyles.boldLabel);
            bulleText = (Text)EditorGUILayout.ObjectField("Bulle", bulleText, typeof(Text), true);
            Giz       = (GizmoDrawer)EditorGUILayout.ObjectField("MainCamera", Giz, typeof(GizmoDrawer), true);
            GUILayout.Space(5);
            if (sceneScript.Actors != null)
            {
                for (int a = 0; a < sceneScript.Actors.Count; a++)
                {
                    EditorGUILayout.BeginHorizontal();
                    sceneScript.Actors[a] = (Actor)EditorGUILayout.ObjectField("Actor : " + a, sceneScript.Actors[a], typeof(Actor), true);;
                    if (GUILayout.Button("Remove Actor"))
                    {
                        sceneScript.Actors.RemoveAt(a);
                        for (int j = 0; j < sceneScript.Events.Count; j++)
                        {
                            sceneScript.Events[j].RemoveActor(a);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            if (GUILayout.Button("Add Actor"))
            {
                sceneScript.Actors.Add(null);
                for (int i = 0; i < sceneScript.Events.Count; i++)
                {
                    sceneScript.Events[i].AddActor();
                }
                this.Repaint();
            }

            GUILayout.Space(10);

            if (sceneScript != null)
            {
                GUILayout.Label("Navigation", EditorStyles.boldLabel);

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Previous"))
                {
                    sceneIndex = sceneIndex == 0 ? 0 : sceneIndex - 1;
                }

                newIndex = EditorGUILayout.IntField(newIndex, GUILayout.Width(60));
                if (GUILayout.Button("Go To"))
                {
                    sceneIndex = newIndex >= sceneScript.Events.Count - 1 ? sceneScript.Events.Count - 1 : newIndex;
                }

                if (GUILayout.Button("Next"))
                {
                    sceneIndex = sceneIndex >= sceneScript.Events.Count - 1 ? sceneScript.Events.Count - 1 : sceneIndex + 1;
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                //Les actions pour chaque events, un par un
                if (sceneScript.Events != null)
                {
                    GUILayout.Label("Event : " + (sceneIndex + 1) + "/" + (sceneScript.Events.Count), EditorStyles.boldLabel);
                }
                GUILayout.BeginHorizontal();

                GUILayout.Space(10);
                //Managing the events
                if (GUILayout.Button("Add Event"))
                {
                    AddEvent(sceneIndex);
                    sceneIndex++;
                }
                if (GUILayout.Button("Remove Event") && sceneScript.Events.Count > 1)
                {
                    RemoveEvent(sceneIndex);
                }

                GUILayout.EndHorizontal();

                if (sceneScript.Events != null)
                {
                    //What does the director do ?
                    GUILayout.Label("Director", EditorStyles.boldLabel);
                    Giz.CamInfo(Vector3.zero, false);
                    sceneScript.Events[sceneIndex].Director = (SceneEventClass.directorAction)EditorGUILayout.EnumPopup(sceneScript.Events[sceneIndex].Director);
                    switch (sceneScript.Events[sceneIndex].Director)
                    {
                    case SceneEventClass.directorAction.DoNothing:
                        //Huh
                        break;

                    case SceneEventClass.directorAction.MoveCamera:
                        sceneScript.Events[sceneIndex].newCameraPosition = EditorGUILayout.Vector2Field("New Position", sceneScript.Events[sceneIndex].newCameraPosition);
                        Giz.CamInfo(sceneScript.Events[sceneIndex].newCameraPosition, true);
                        break;

                    case SceneEventClass.directorAction.DisplayImage:
                        sceneScript.Events[sceneIndex].imageToDisplay = (Sprite)EditorGUILayout.ObjectField("Image : ", sceneScript.Events[sceneIndex].imageToDisplay, typeof(Sprite), false);
                        break;

                    case SceneEventClass.directorAction.RemoveImage:
                        //Will be taken care of in the reader
                        break;

                    case SceneEventClass.directorAction.ZoomIn:
                        //Zoom Level
                        break;
                    }

                    GUILayout.Space(10);

                    //What does the actors do ?
                    scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.MaxWidth(512));
                    for (int i = 0; i < sceneScript.Actors.Count; i++)
                    {
                        if (sceneScript.Actors[i] != null)
                        {
                            GUILayout.Space(10);



                            GUILayout.BeginHorizontal();
                            GUILayout.Label(sceneScript.Actors[i].icon, GUILayout.Width(100), GUILayout.Height(100));
                            GUILayout.BeginVertical();
                            GUILayout.Label(sceneScript.Actors[i].name, EditorStyles.boldLabel);
                            sceneScript.Events[sceneIndex].act[i] = (SceneEventClass.actorAction)EditorGUILayout.EnumPopup("Action ", sceneScript.Events[sceneIndex].act[i]);

                            switch (sceneScript.Events[sceneIndex].act[i])
                            {
                            case SceneEventClass.actorAction.DoNothing:
                                break;

                            case SceneEventClass.actorAction.Speak:
                                sceneScript.Events[sceneIndex].txtAction[i] = EditorGUILayout.TextArea(sceneScript.Events[sceneIndex].txtAction[i], speechbuble, GUILayout.Height(60), GUILayout.ExpandWidth(true));
                                if (GUILayout.Button("ShowInText"))
                                {
                                    if (bulleText != null)
                                    {
                                        bulleText.text = sceneScript.Events[sceneIndex].txtAction[i];
                                    }
                                    else
                                    {
                                        Debug.LogWarning("Need a Text for displaying purpose");
                                    }
                                }
                                break;

                            case SceneEventClass.actorAction.WalkTo:
                                sceneScript.Events[sceneIndex].new_positions[i] = EditorGUILayout.Vector2Field("Move Toward", sceneScript.Events[sceneIndex].new_positions[i]);

                                break;
                            }

                            int       numberOfVector = 0;
                            Vector3[] vectors        = new Vector3[0];

                            for (int a = 0; a < sceneScript.Actors.Count; a++)
                            {
                                if (sceneScript.Events[sceneIndex].act[a] == SceneEventClass.actorAction.WalkTo)
                                {
                                    numberOfVector++;
                                    Vector3[] _v = vectors;
                                    vectors = new Vector3[numberOfVector];
                                    vectors[vectors.Length - 1] = sceneScript.Events[sceneIndex].new_positions[a];
                                    for (int j = 0; j < _v.Length; j++)
                                    {
                                        vectors[j] = _v[j];
                                    }
                                    if (Giz != null)
                                    {
                                        if (vectors != null)
                                        {
                                            Giz.CubeInfo(vectors);
                                        }
                                        else
                                        {
                                            Giz.CubeInfo(false);
                                        }
                                    }
                                }
                                SceneView.RepaintAll();
                            }

                            GUILayout.EndVertical();
                            GUILayout.EndHorizontal();
                        }
                    }
                }

                GUILayout.Space(10);

                EditorGUILayout.EndScrollView();
            }
        }
        if (EditorGUI.EndChangeCheck())
        {
            EditorUtility.SetDirty(sceneScript);
        }
    }