Create "Editor" folder on "Asset" folder first.
and make a "ProjectBuilder.cs" file in "Editor" folder.

* This script tested on Unity 2018

using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;

class ProjectBuilder {
    static string[] SCENES = FindEnabledEditorScenes();
    static string APP_NAME = "Your Project name";
    static string TARGET_DIR = "build";

    [MenuItem ("ForYou/CI/Build IOS")]
    staticvoidPerformiOSBuild ()
    {
        BuildOptions opt = BuildOptions.AcceptExternalModificationsToPlayer;
                    /*
                     BuildOptions.SymlinkLibraries |
                     BuildOptions.Development |
                     BuildOptions.ConnectWithProfiler |
                     BuildOptions.AllowDebugging |
                     BuildOptions.Development; 
                     */
 
        //PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK; 
        //PlayerSettings.iOS.targetOSVersionString = "11.0";
        //PlayerSettings.statusBarHidden = true;
        //PlayerSettings.iOS.cameraUsageDescription = "ARMode";
 
         PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, ScriptingImplementation.IL2CPP);
         char sep = Path.DirectorySeparatorChar;
         string buildDirectory = Path.GetFullPath(".") + sep + TARGET_DIR;
         Directory.CreateDirectory(buildDirectory);
 
         string BUILD_TARGET_PATH = buildDirectory + "/ios";
         Directory.CreateDirectory(BUILD_TARGET_PATH);
 
         GenericBuild(SCENES, BUILD_TARGET_PATH, BuildTargetGroup.iOS, BuildTarget.iOS, opt);
    }

    [MenuItem ("ForYou/CI/Build Android")]
    staticvoidPerformAndroidBuild ()
    {
        string target_filename = APP_NAME + ".apk";
        GenericBuild(SCENES, target_filename, BuildTargetGroup.Android, BuildTarget.Android ,BuildOptions.None);
    }
    
    [MenuItem ("ForYou/CI/Build Window")]
    static void PerformWindowsBuild () {
        string target_filename = APP_NAME + ".exe";
        GenericBuild(SCENES, target_filename, BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows, BuildOptions.None);
    }

    [MenuItem ("ForYou/CI/Build Mac")]
    static void PerformMacBuild () {
        string target_filename = APP_NAME + ".app";
        GenericBuild(SCENES, target_filename, BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX, BuildOptions.None);
    }

   private static string[] FindEnabledEditorScenes() {
      List<string> EditorScenes = new List<string>();
      foreach(EditorBuildSettingsScene scene in EditorBuildSettings.scenes) {
         if (!scene.enabled) continue;
         EditorScenes.Add(scene.path);
      }
      return EditorScenes.ToArray();
   }

    static void GenericBuild(string[] scenes, string target_filename, BuildTargetGroup build_group, BuildTarget build_target, BuildOptions build_options)
    {
        EditorUserBuildSettings.SwitchActiveBuildTarget(build_group, build_target);
        UnityEditor.Build.Reporting.BuildReport res = BuildPipeline.BuildPlayer(scenes, target_filename, build_target, build_options);
    }
}


You could copy & paste it. and Test it on Unity3d Editor.

Next time, Continue.



2018/04/24 08:22 2018/04/24 08:22
If you use the uGUI for making mobile UI Event, perhaps, Your code like below code.

* button script (Example): Mobile has just 3 events. Pressed, Exit from a button (Cancel), Deattached from a button (OK).

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class CommonButton : MonoBehaviour, IPointerDownHandler, IPointerExitHandler, IPointerClickHandler {

GameObject selectedObject;
 
//Process for Selected button
public void OnPointerDown(PointerEventData eventData) {
selectedObject = gameObject;
//Blah blah... something
}

//Process for cancel button
public void OnPointerExit(PointerEventData eventData) {
selectedObject = null;
//Blah blah... something
}

//Process for OK button
public void OnPointerClick(PointerEventData eventData) {
if (selectedObject != gameObject) return;
selectedObject = null;
//Blah blah... something
}
}


Normally, We attach this code @ each button object.
It is terrible for maintenance.

If someone wants to change some behavior, We should change all.

however, we could solve this problem by simple Inheritance.

1. Make a parents class for sharing.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class CommonButton : MonoBehaviour, IPointerDownHandler, IPointerExitHandler, IPointerClickHandler {

 GameObject selectedObject;

 public void OnPointerDown(PointerEventData eventData) {
 selectedObject = gameObject;
 PressedButton();
 }

 public void OnPointerExit(PointerEventData eventData) {
 selectedObject = null;
 CancelButton();
 }

 public void OnPointerClick(PointerEventData eventData) {
 if (selectedObject != gameObject) return;
 selectedObject = null;
 OKButton();
 }

 public virtual void PressedButton() { } //Virtual method is key point
 public virtual void CancelButton() { }
 public virtual void OKButton() { }
}


2. Make a child class for attaching to each button.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BehaviourRadioMenus : CommonButton {

 override public void PressedButton() {
 RevealDesc();
 }

 override public void CancelButton() {
 HideDesc();
 }

 override public void OKButton() {
 HideDesc();
 }

 void RevealDesc() {
 }

 void HideDesc() {
 }
}


Cheers!
2018/03/04 06:27 2018/03/04 06:27

I get it every time when I got code test.


using System;

namespace NodeTest
{
    class Program
    {
        static void Main(string[] args)
        {
            const string STR_VALUE = "10524";
            ListNode headNode = null;
            ListNode pointNode = null;
 
             MakeNode(ref headNode, null, STR_VALUE);

             for (int i = 0; i < STR_VALUE.Length; i++)
             {
                 for (int j = i+1; j < STR_VALUE.Length; j++)
                 {
                     if (GetNode(headNode, i).val > GetNode(headNode, j).val)
                     {
                         int x = GetNode(headNode, i).val;
                         GetNode(headNode, i).val = GetNode(headNode, j).val;
                         GetNode(headNode, j).val = x;
                     }
                 }
             }

             pointNode = headNode;
             while(true)
             {
                 Console.WriteLine(pointNode.val.ToString());
                 if (pointNode.next == null) break;
                 pointNode = pointNode.next;
             }
    }

     static void MakeNode(ref ListNode currentnode, ListNode previousnode, string str)
     {
         if (str.Length <= 0) return;
         currentnode = new ListNode(int.Parse(str.Substring(0, 1)));
         if (previousnode != null) {
             previousnode.next = currentnode;
         }
         ListNode dummynode = null;
         MakeNode(ref dummynode, currentnode, str.Substring(1));
     }

     static ListNode GetNode(ListNode headNode, int idx)
     {
         ListNode currentnode = headNode;
         for (int i = 0; i < idx; i++)
         {
             currentnode = currentnode.next;
         }
         return currentnode;
     }
 }

 public class ListNode {
     public int val;
     public ListNode next;
     public ListNode(int x) { val = x; }
 }
}




2018/02/11 20:07 2018/02/11 20:07
TAG ,